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 |
helllo sir , what is the main use of the pointer ,array ,and the structure with the example of a programe
what will be the output: main(){char ch;int a=10;printf("%d",ch);}
36 Answers Accenture, TCS, Wipro,
What is 'bus error'?
Write a program to enter the name and age. If age>28 then find salary categories. if age<28 then find that you are gaduate or not.
write a program to display the numbers in the following 4 4 3 3 2 2 1 1 0 1 1 2 2 3 3 4 4
What is false about the following A compound statement is a.A set of simple statments b.Demarcated on either side by curly brackets c.Can be used in place of simple statement d.A C function is not a compound statement.
What are the types of data types and explain?
Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.
What is the benefit of using an enum rather than a #define constant?
Compare interpreters and compilers.
How can you dynamically allocate memory in C?
How does variable declaration affect memory?