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 |
Synonymous with pointer array a) character array b) ragged array c) multiple array d) none
What is bubble sort in c?
what are the stoge class in C and tel the scope and life time of it?
How will you allocate memory to double a pointer?
what is the difference between declaration ,defenetion and initialization of a variable?
34.what are bitwise shift operators? 35.what are bit fields? What is the use of bit fields in a structure declaration? 36.what is the size of an integer variable? 37.what are the files which are automatically opened when a c file is executed? 38.what is the little endian and big endian? 39.what is the use of fflush() function? 40.what is the difference between exit() and _exit() functions? 41.where does malloc() function get the memory? 42.what is the difference between malloc() and calloc() function? 43.what is the difference between postfix and prefix unary increment operators?
what is the function of .h in #include<stdio.h> in c ?
23 Answers HCL, IBM, Wipro,
What do you mean by Recursion Function?
How can you call a function, given its name as a string?
what are the 10 different models of writing an addition program in C language?
If the static variable is declared as global, will it be same as extern?
what is the diff b/w static and non static variables in C. Give some examples plz.