C++ Programming - OOPS Concepts - Discussion
Discussion Forum : OOPS Concepts - General Questions (Q.No. 47)
47.
What will happen if a class is not having any name?
Discussion:
25 comments Page 2 of 3.
Monika said:
9 years ago
Not satisfied with the answer of this question please elaborate.
Jatin said:
10 years ago
@Rahul.
I'm not getting any output as per your code.
I'm not getting any output as per your code.
Chintan said:
10 years ago
If you create class but not having any name, gives compilation error. So I think answer C is right.
Djain said:
1 decade ago
Then, how will you instantiate that classes?
Naveen pateriya vidisha said:
1 decade ago
Nice discussion its possible blindly to create a name less class.
Rahul said:
1 decade ago
#include<iostream.h>
class { public : int x; }a; //a is the object of this class
int main(){
a.x=10;
cout<<"a="<<a.x;
return 0;
}
Execute the above code one can get to know about class without name.
class { public : int x; }a; //a is the object of this class
int main(){
a.x=10;
cout<<"a="<<a.x;
return 0;
}
Execute the above code one can get to know about class without name.
Rinku said:
1 decade ago
How can possible without class name constructor and destructor?
Rhuda said:
1 decade ago
Its possible in C++ but is this true for java?
Seema said:
1 decade ago
We can create objects of nameless class but at the time of creation of the class.
For example this perfect.
class { public : intx }a; //a is the object of this class
main(){
a.x=10;
cout<<"a="<<a.x;
}
For example this perfect.
class { public : intx }a; //a is the object of this class
main(){
a.x=10;
cout<<"a="<<a.x;
}
Kushal tewatia said:
1 decade ago
Can somebody give the example of a class having without name.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers