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



can we declare a function inside the structure? ex: struct book { int pages; flo..

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

can we declare a function inside the structure? ex: struct book { int pages; flo..

Answer / 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

More C Interview Questions

What is the use of sizeof?

0 Answers  


Explain the difference between exit() and _exit() function?

0 Answers  


what is difference between procedural language and functional language ?

4 Answers   Wipro,


Where are some collections of useful code fragments and examples?

0 Answers   Celstream,


Is c procedural or object oriented?

0 Answers  






What is string function c?

0 Answers  


One of the Institutes contains 5 student groups. Every group contains 4 students. Institute wants to store student group’s details in array. Group should contain group member’s details (name and registration number and age), project name, and mark of the group.

0 Answers  


how to print value of e(exp1)up to required no of digits after decimal?

1 Answers  


Is anything faster than c?

0 Answers  


Print all numbers which has a certain digit in a certain position eg: number=45687 1 number=4 2 number=5 etc

4 Answers  


What are the difference between a free-standing and a hosted environment?

0 Answers   Infogain,


What is I ++ in c programming?

0 Answers  


Categories