Click here to Skip to main content
15,892,809 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to retrieve public folders list in an exchange server Pin
lavanm1-Nov-04 18:45
lavanm1-Nov-04 18:45 
QuestionHow to create Web Interface using MFC Program Pin
pubududilena1-Nov-04 18:16
pubududilena1-Nov-04 18:16 
AnswerRe: How to create Web Interface using MFC Program Pin
alex.barylski1-Nov-04 20:00
alex.barylski1-Nov-04 20:00 
AnswerRe: How to create Web Interface using MFC Program Pin
Michael P Butler1-Nov-04 23:54
Michael P Butler1-Nov-04 23:54 
GeneralGDIPlus cast *Image to Bitmap Pin
Nicholas Cardi1-Nov-04 17:12
Nicholas Cardi1-Nov-04 17:12 
Questionhow to get char (or) string from comport Pin
vc-programmer-1-Nov-04 16:43
vc-programmer-1-Nov-04 16:43 
AnswerRe: how to get char (or) string from comport Pin
jan larsen2-Nov-04 0:49
jan larsen2-Nov-04 0:49 
GeneralCreating an array of classes... Pin
viru_lent1-Nov-04 13:51
viru_lent1-Nov-04 13:51 
Initializing an Array in a managed class viru_lent 19:47 1 Nov '04
Greetings everyone. I'm just playing around with a very basic class, which I have probably really screwed up, but am looking to create an array of the classes. This is just a module for me to learn how to play with some of these tricks. What is happening, is the variables all get passed, and stored, but my output is only the last inputted infomation, not what should be the prior stored information in the array. I believe it has something to do with using the pointers on the strings, but I haven't figured out anything else to do with them yet. I'm still teaching myself all this fun stuff, so bear with the easy questions.


/*
I'm trying to create my own class to store information about a person
in this example, an employee. This is just a test run to be able to
create a class, instantiate an aray of objects based on that class,
and update them as we need to input the record. This is just the first block of a larger scope program.
*/
#using "mscorlib.dll" //ignore the quotes, had to alter to use HTML here
using namespace System;

__gc class NameStorage
{

public:

String* GetName()
{
fullName = String::Copy(String::Concat(lastName,", ", firstName));
return fullName;
}

String* GetCompany()
{
return company;
}

double GetSalary()
{
return salary;
}

void SetFirstName(String* input)
{
firstName = String::Copy(input);
}

void SetLastName(String* input)
{
lastName = String::Copy(input);
}

void SetCompany(String* input)
{
company = String::Copy(input);
}

void SetSalary(double input)
{
salary = input;
}

private:
String *firstName, *lastName, *company, *fullName = "";
double salary = 0;
};

void main()
{
NameStorage *names[] = new NameStorage*[3];

for(int i = 0; i < 3; i++)
{
// Error is coming in that the individual elements of the array are not
// being updated independently.
Console::Write("First Name: ");
names[i]->SetFirstName(Console::ReadLine());
Console::Write("Last Name: ");
names[i]->SetLastName(Console::ReadLine());
Console::Write("Salary: ");
names[i]->SetSalary(Convert::ToDouble(Console::ReadLine()));
Console::WriteLine(names[0]->GetName());
Console::WriteLine(Convert::ToDouble(names[0]->GetSalary()));
Console::WriteLine(names[1]->GetName());
Console::WriteLine(Convert::ToDouble(names[1]->GetSalary()));
Console::WriteLine(names[2]->GetName());
Console::WriteLine(Convert::ToDouble(names[2]->GetSalary()));
}

return;

}


This is an edited version of the code, I think I am missing my initialization of the array elements, but with them, i was getting the same results. Again, thank you for any insight to this, my proffessor is an old FORTRAN COBOL programmer who has never seen any of this stuff, and is no help at all



Virulent
Aspiring Programming Master of All Languages
Still has All Languages to go Dead | X|
GeneralRe: Creating an array of classes... Pin
GDavy2-Nov-04 1:48
GDavy2-Nov-04 1:48 
GeneralRe: Creating an array of classes... Pin
viru_lent2-Nov-04 4:21
viru_lent2-Nov-04 4:21 
General? about wav files Pin
tom_dx1-Nov-04 13:42
tom_dx1-Nov-04 13:42 
GeneralRe: ? about wav files Pin
KRowe1-Nov-04 16:56
KRowe1-Nov-04 16:56 
GeneralGetting the size of a block of code Pin
Xzyx987X1-Nov-04 12:34
Xzyx987X1-Nov-04 12:34 
GeneralRe: Getting the size of a block of code Pin
Andrew Walker1-Nov-04 15:21
Andrew Walker1-Nov-04 15:21 
GeneralRe: Getting the size of a block of code Pin
Xzyx987X1-Nov-04 21:44
Xzyx987X1-Nov-04 21:44 
GeneralRe: Getting the size of a block of code Pin
jan larsen2-Nov-04 0:57
jan larsen2-Nov-04 0:57 
GeneralRe: Getting the size of a block of code Pin
Maximilien2-Nov-04 2:47
Maximilien2-Nov-04 2:47 
GeneralRe: Getting the size of a block of code Pin
jan larsen2-Nov-04 3:29
jan larsen2-Nov-04 3:29 
GeneralRe: Getting the size of a block of code Pin
Anonymous2-Nov-04 7:49
Anonymous2-Nov-04 7:49 
GeneralThreading problem Pin
User 9148331-Nov-04 11:35
User 9148331-Nov-04 11:35 
GeneralRe: Threading problem Pin
Blake Miller2-Nov-04 7:59
Blake Miller2-Nov-04 7:59 
GeneralSplitter inside a Tab Window Pin
Ali Niaz1-Nov-04 11:17
Ali Niaz1-Nov-04 11:17 
GeneralRe: Splitter inside a Tab Window Pin
Selvam R2-Nov-04 3:01
professionalSelvam R2-Nov-04 3:01 
GeneralRe: Splitter inside a Tab Window Pin
Selvam R2-Nov-04 3:01
professionalSelvam R2-Nov-04 3:01 
GeneralRe: Splitter inside a Tab Window Pin
Ali Niaz2-Nov-04 4:17
Ali Niaz2-Nov-04 4:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.