Untitled
unknown
c_cpp
2 years ago
816 B
8
Indexable
#include <iostream>
#include <string>
#include <array>
class Person
{
public:
Person()
{
name = "";
age = 0;
}
Person( std::string n, int a )
{
name = n;
age = a;
}
void setInfo( std::string n, int a )
{
name = n;
age = a;
}
void showInfo()
{
std::cout << "Imie: " << name << "\nAge: " << age << "\n\n";
}
private:
std::string name;
int age;
};
int main()
{
std::array< Person, 10000 > persons;
for( int i = 0; i < persons.size(); ++i )
{
Person person;
persons[ i ] = person;
}
int i = 1;
for(auto& p : persons)
{
std::cout << i;
p.showInfo();
++i;
}
return 0;
}
Editor is loading...
Leave a Comment