Student class

smemamian (2)
How can I have a class as follows:
cin:
student 1 : ID,Name,Last name,Address
.
.
.
.
to
student 10 : ID,Name,Last name,Address

And have the ability to search(Based on ID And Last name).

Tnx
SirSen (8)
use a data structure:
1
2
3
4
5
6
7
8
9
10
11
12
struct students{
int ID;
string Name; // use char if u want
string Lastname; // use char if u want
string Adress;
}
//declaring the student and each characteristic
students student1;
student1.ID= "1232132";
student1.Name= "Sherlock";
student1.Lastname= "Holmes";
student1.Adress="221b Baker Street"

well, as for the ability to search i dont know yet
Last edited on
Smac89 (10)
use a for loop to search based on highest ID or based on highest ASCII code of the name. reading in the names as int will work for the ascii method

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
struct Student
{
int ID;
char* Name;
char* LastName;
char* Address;
};

Student* getperson()//some function
{
  Student* person1 = new Student;
  person1->ID = 12312;
  person1->Name = "My Name";
  person1->LastName = "Last name";
  person1->Address = "123 srwf kl";
  
  return person1
}
Last edited on
Darkmaster (331)
he asked for a class, not a struct
maeriden (230)
Structs and classes are the same thing, except for the default access level
Darkmaster (331)
@ maeriden: hm, did some reading and you're right. and i was sooo sure it's not the same :D
Registered users can post here. Sign in or register to post.