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

how to construct a simulator keeping the logical boolean gates in c

0 Answers  


Which node is more powerful and can handle local information processing or graphics processing?

0 Answers  


how to find that no is int or float?

5 Answers  


What is the use of define in c?

0 Answers  


What is null pointer constant?

0 Answers  






how we do lcm of two no using c simple if while or for statement

1 Answers  


What is null character in c?

0 Answers  


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

1 Answers  


A program to allow an input operand and operator from the operator and read on the display and output operand.

0 Answers  


can we write a program in c for printf and scanf without using header file stdio.h

1 Answers  


Write the syntax and purpose of a switch statement in C.

0 Answers   Adobe,


1. Write a C program to count the number of occurrence of a specific word in the given strings. (for e.g. Find how many times the word “live” comes in the sentence “Dream as if you’ll live forever, live as if you’ll die today ”)

12 Answers   Eskom, TCS,


Categories