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 |
What is the restrict keyword in C?
What is the code in while loop that returns the output of given code?
Which type of language is c?
Is c still used in 2019?
#define PRINT(int) printf("int = %d ",int) main() {< BR> intx,y,z; x=03;y=02;z=01; PRINT(x^x); z<<=3;PRINT(x); y>>=3;PRINT(y); }
what is difference b/w extern & volatile variable??
Give differences between - new and malloc() , delete and free() ?
c programming of binary addition of two binary numbers
What is the output from this program? #include <stdio.h> void do_something(int *thisp, int that) { int the_other; the_other = 5; that = 2 + the_other; *thisp = the_other * that; } int main(void) { int first, second; first = 1; second = 2; do_something(&second, first); printf("%4d%4d\n", first, second); return 0; }
What is the output for the program given below typedef enum grade{GOOD,BAD,WORST,}BAD; main() { BAD g1; g1=1; printf("%d",g1); }
Write a program using two-dimensional array that lists the odd numbers and even numbers separately in a 12 input values.
what is the difference between postfix and prefix unary increment operators?