can we declare a function inside the structure?
ex: struct book
{
int pages;
float price;
int library(int,float);
}b;
is the above declaration correct? as it has function
declaration?

Answers were Sorted based on User's Feedback



can we declare a function inside the structure? ex: struct book { int pages; flo..

Answer / srinivasroyal

In CPP the above declaration is correct. But in case of C it
is not.

Is This Answer Correct ?    7 Yes 2 No

can we declare a function inside the structure? ex: struct book { int pages; flo..

Answer / vignesh1988i

no , it is not possible in C.. here structure is not a defined class.. so it is not permitted..

in C++ we can use , that is called class , A derived datatype from a structure :)

class class_name
{
ACCESS SPECIFIER : (private/public/protected)
decleration of data member;
member fucntions definitions
{
......
.........
}
};



thank u

Is This Answer Correct ?    4 Yes 3 No

Post New Answer

More C Interview Questions

what is the mean of c languages.

1 Answers   Polaris,


Program to display given 3 integers in ascending order

1 Answers   N Tech,


What is the size of array float a(10)?

0 Answers  


Can we add pointers together?

0 Answers  


what is difference between overriding and overloading?

1 Answers  


what is the use of c program?

4 Answers   Synergy, Web Synergies,


write a program to display & create a rational number

1 Answers   HCL, TCS,


how to multiply two number taking input as a string (considering sum and carry )

2 Answers   Wipro,


What will be the output of following program #include main() { int x,y = 10; x = y * NULL; printf("%d",x); }

1 Answers  


What is class and object in c?

0 Answers  


Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.

0 Answers   Wipro,


What are c identifiers?

0 Answers  


Categories