Dynamic memory
-
Hi there Can anyone advise. I have a class called Employee ok. Now i want the user to create employees by adding a name, empid and so on. Creating an Employee object // Employee *NewEmp = new Emp ?? I want the new employees details in a file .dat it keeps on creating one employee overriding the previous info. How can i create more than one employee Hit me over the knuckles if im way of! Am i using new wrong? or am i missing the hole new concept totaly thanks:-D
-
Hi there Can anyone advise. I have a class called Employee ok. Now i want the user to create employees by adding a name, empid and so on. Creating an Employee object // Employee *NewEmp = new Emp ?? I want the new employees details in a file .dat it keeps on creating one employee overriding the previous info. How can i create more than one employee Hit me over the knuckles if im way of! Am i using new wrong? or am i missing the hole new concept totaly thanks:-D
if your class is written with contructor
Employee::Employee(CString strName, int iAge)
{
this->m_strName = strName;
this->m_iAge = iAge;
}you probably could initiate your object as such
Employee *pEmp = new Employee(_T("Someone"), 22);
these are basic, man Sonork 100.41263:Anthony_Yio
-
Hi there Can anyone advise. I have a class called Employee ok. Now i want the user to create employees by adding a name, empid and so on. Creating an Employee object // Employee *NewEmp = new Emp ?? I want the new employees details in a file .dat it keeps on creating one employee overriding the previous info. How can i create more than one employee Hit me over the knuckles if im way of! Am i using new wrong? or am i missing the hole new concept totaly thanks:-D
-
Hi there Can anyone advise. I have a class called Employee ok. Now i want the user to create employees by adding a name, empid and so on. Creating an Employee object // Employee *NewEmp = new Emp ?? I want the new employees details in a file .dat it keeps on creating one employee overriding the previous info. How can i create more than one employee Hit me over the knuckles if im way of! Am i using new wrong? or am i missing the hole new concept totaly thanks:-D
bhangie wrote: // Employee *NewEmp = new Emp ?? I assume you meant
Employee *NewEmp = new Emp**loyee**
? bhangie wrote: I want the new employees details in a file .dat it keeps on creating one employee overriding the previous info. So do you have something akin to:for each employee in list
{
open .dat file
write employee info to file
close .dat file
}In other words, after writing all employees to the .dat file, what one employee is in the file: the first one in the list or the last? bhangie wrote: Am i using new wrong? or am i missing the hole new concept totaly You are using it correctly. However, at this point, there is no way to know if your design is sound.
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?