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?
Answer Posted / 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 View All Answers
What functions are used for dynamic memory allocation in c language?
What is the difference between procedural and declarative language?
Is null a keyword in c?
Why is event driven programming or procedural programming, better within specific scenario?
How many levels of indirection in pointers can you have in a single declaration?
What is array of pointers to string?
Can you please explain the difference between strcpy() and memcpy() function?
Write a function which takes as parameters one regular expression(only ? and * are the special characters) and a string and returns whether the string matched the regular expression.
What are the advantages of Macro over function?
Explain the advantages of using macro in c language?
Is register a keyword in c?
What is the significance of scope resolution operator?
Why is c called a structured programming language?
What is volatile variable in c?
What is a rvalue?