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
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 |
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 |
write an interactive program to generate the divisors of a given integer.
Explain how can you determine the size of an allocated portion of memory?
What is openmp in c?
what is the purpose of the code, and is there any problem with the code? int f( int n, int l, int r ) { return (n << l) >> r; }
write a program structure to find average of given number
main() { int i,j,A; for(A=-1;A<=1;A++) prinf("%d\t",!!A); }
Is reference used in C?
How can I automatically locate a programs configuration files in the same directory as the executable?
Is boolean a datatype in c?
C program to find frequency of each character in a text file?
What is the use of static variable in c?
Write a program which take a integer from user and tell whether the given variable is squar of some number or not. eg: is this number is 1,4,9,16... or not