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?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a stream?

655


The performance of an operation in several steps with each step using the output of the preceding step a) recursion b) search c) call by value d) call by reference

679


What is the difference between the expression “++a” and “a++”?

652


How do you view the path?

672


When can a far pointer be used?

593






What is double pointer in c?

593


How can I get back to the interactive keyboard if stdin is redirected?

673


How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?

588


Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.

3132


What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?

819


What is the maximum no. of arguments that can be given in a command line in C.?

674


If a five digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits.For example if the number that is input is 12391 then the output should be displayed as 23402

3253


What is the ANSI C Standard?

782


to print the salary of an employee according to follwing calculation: Allowances:HRA-20% of BASIC,DA-45% of BASIC,TA-10%. Deductions:EPF-8% of BASIC,LIC-Rs.200/-Prof.Tax:Rs.200/- create c language program?

1575


A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference

641