Click here to Skip to main content
15,900,511 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Your thoughts on this singleton implementation Pin
Anonymous18-Jun-03 3:56
Anonymous18-Jun-03 3:56 
GeneralRe: Your thoughts on this singleton implementation Pin
AlexO18-Jun-03 4:13
AlexO18-Jun-03 4:13 
GeneralSetting a radio button as the default choice Pin
Jay Hova17-Jun-03 9:41
Jay Hova17-Jun-03 9:41 
GeneralRe: Setting a radio button as the default choice Pin
valikac17-Jun-03 10:02
valikac17-Jun-03 10:02 
GeneralRe: Setting a radio button as the default choice Pin
David Crow17-Jun-03 10:51
David Crow17-Jun-03 10:51 
GeneralRe: Setting a radio button as the default choice Pin
Ryan Binns17-Jun-03 16:18
Ryan Binns17-Jun-03 16:18 
GeneralRe: Setting a radio button as the default choice Pin
Jay Hova18-Jun-03 4:16
Jay Hova18-Jun-03 4:16 
QuestionHow do you create new object using <vector>? Pin
kleft17-Jun-03 9:06
kleft17-Jun-03 9:06 
I'm having trouble understanding the use of vectors in C++, perhaps someone could comment about this snippet of code (found on the internet). In particular, the area I'm most confused about is in bold below...

How do you add elements to the list without having to assign objects names first? I'm trying to find a way to nest vectors of stuctures. From posts on this board, I've found that CArray is not recommended.


Here's the snippet of code... It's an array of people, each may have a variable number of nickels (dimes and pennies could be added).

************ nickel.h ********************************
#include < list >
#include < vector >
#include < algorithm >
#include < iostream >
using namespace std;

class nickel
{
public:
nickel();
virtual ~nickel();
};

class person
{
public:
person();
virtual ~person();

void addNickel(nickel *n) {myNickels.push_back(n);}
void removeLastNickel() {myNickels.erase(myNickels.end());}
private:
list < nickel * > myNickels;
};


**********KDlg.cpp*******************
void CKDlg::OnNewPerson()
{
//These don't work
NewNickel = new nickel;
NewPerson = new person; //doesn't work
NewPerson.addNickel(NewNickle) //expected constant expression

//This works, but forces me to assign objects to each element of the array...seems to defeat the purpose of a resizable array.
person p1,p2;
nickel n1,n2,n3;
p1.addNickel(&n1);
}

AnswerRe: How do you create new object using ? Pin
AlexO17-Jun-03 9:14
AlexO17-Jun-03 9:14 
Generalusing SP_DRVINFO_DATA_V2 instead of SP_DRVINFO_DATA_V1 Pin
tessierjf17-Jun-03 8:28
tessierjf17-Jun-03 8:28 
Generalstoring data in Memory and accessing it for playback Pin
johnstonsk17-Jun-03 7:58
johnstonsk17-Jun-03 7:58 
GeneralRe: storing data in Memory and accessing it for playback Pin
AlexO17-Jun-03 8:39
AlexO17-Jun-03 8:39 
GeneralRe: storing data in Memory and accessing it for playback Pin
AlexO17-Jun-03 8:47
AlexO17-Jun-03 8:47 
GeneralRe: storing data in Memory and accessing it for playback Pin
johnstonsk17-Jun-03 8:47
johnstonsk17-Jun-03 8:47 
GeneralActiveX control stock property issue. Pin
Marion2817-Jun-03 7:30
Marion2817-Jun-03 7:30 
GeneralFunction to pass an CArray or Structure.. Pin
RobJones17-Jun-03 6:58
RobJones17-Jun-03 6:58 
GeneralRe: Function to pass an CArray or Structure.. Pin
basementman17-Jun-03 7:05
basementman17-Jun-03 7:05 
GeneralRe: Function to pass an CArray or Structure.. Pin
RobJones17-Jun-03 7:12
RobJones17-Jun-03 7:12 
GeneralRe: Function to pass an CArray or Structure.. Pin
peterchen17-Jun-03 7:12
peterchen17-Jun-03 7:12 
Generalnon-blocking mode in sockets Pin
User 988517-Jun-03 6:33
User 988517-Jun-03 6:33 
GeneralRe: non-blocking mode in sockets Pin
David Crow17-Jun-03 6:51
David Crow17-Jun-03 6:51 
GeneralRe: non-blocking mode in sockets Pin
User 988517-Jun-03 7:04
User 988517-Jun-03 7:04 
GeneralRe: non-blocking mode in sockets Pin
valikac17-Jun-03 7:46
valikac17-Jun-03 7:46 
GeneralRe: non-blocking mode in sockets Pin
User 988517-Jun-03 7:59
User 988517-Jun-03 7:59 
GeneralRe: non-blocking mode in sockets Pin
valikac17-Jun-03 8:09
valikac17-Jun-03 8:09 

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.