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 happens if a header file is included twice?

0 Answers  


Explain modulus operator. What are the restrictions of a modulus operator?

0 Answers  


Are enumerations really portable?

0 Answers  


What is return in c programming?

0 Answers  


write a program to print infinte number

4 Answers  






what are two kinds of java

2 Answers  


What is the difference between c and python?

0 Answers  


What is the proper way of these job Tell me about there full work

0 Answers   EDS,


What is operator promotion?

0 Answers  


What is the use of pragma in embedded c?

0 Answers  


Write a program to generate the first n terms in the series --- 2,3,5,7,11,...,17

0 Answers  


What is #include stdlib h?

0 Answers  


Categories