I have a question. Is it possible to create multiple objects during run time for classes or structures?
#include<iostream>
#include<conio.h>
using namespace std;
struct node
{
int no;
};
int main()
{
int i;
for(i=0;i<4;i++)
{
struct node s[i];
}
cout<<"Enter the values";
for(i=0;i<4;i++)
{
cin>>s[i].no;
}
cout<<"The values are:";
for(i=0;i<4;i++)
{
cout<<s[i].no<<endl;
}
getch();
return 0;
}
I tried the method above , but didn't succeed . Any help would be appreciated
structbefore a struct name is C-syntax,using namespaceis C++-syntax. It's fine to use libraries from either in a C++ program, but I would urge you not to mix up C-syntaxism in there.