Click here to Skip to main content
15,904,339 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how to share data between two dlls.? Pin
mbatra3128-Aug-12 19:30
mbatra3128-Aug-12 19:30 
QuestionIs it possible to use std::wstring parameter type in DLL? Pin
Falconapollo27-Aug-12 23:57
Falconapollo27-Aug-12 23:57 
AnswerRe: Is it possible to use std::wstring parameter type in DLL? Pin
CPallini28-Aug-12 0:29
mveCPallini28-Aug-12 0:29 
AnswerRe: Is it possible to use std::wstring parameter type in DLL? Pin
Richard MacCutchan28-Aug-12 7:41
mveRichard MacCutchan28-Aug-12 7:41 
QuestionIPreviewHandler generate BEX error Pin
Le@rner27-Aug-12 22:19
Le@rner27-Aug-12 22:19 
QuestionSending preformed UDP Packets to localhost with C++ Pin
Member 936259727-Aug-12 12:31
Member 936259727-Aug-12 12:31 
QuestionC++ : pass a string array to LPARAM Pin
Atlence27-Aug-12 6:57
Atlence27-Aug-12 6:57 
AnswerRe: C++ : pass a string array to LPARAM Pin
Richard MacCutchan27-Aug-12 7:17
mveRichard MacCutchan27-Aug-12 7:17 
GeneralRe: C++ : pass a string array to LPARAM Pin
Atlence27-Aug-12 11:07
Atlence27-Aug-12 11:07 
GeneralRe: C++ : pass a string array to LPARAM Pin
Richard MacCutchan27-Aug-12 21:24
mveRichard MacCutchan27-Aug-12 21:24 
AnswerRe: C++ : pass a string array to LPARAM Pin
Maximilien27-Aug-12 9:22
Maximilien27-Aug-12 9:22 
AnswerRe: C++ : pass a string array to LPARAM Pin
CPallini27-Aug-12 9:43
mveCPallini27-Aug-12 9:43 
GeneralRe: C++ : pass a string array to LPARAM Pin
pasztorpisti27-Aug-12 10:32
pasztorpisti27-Aug-12 10:32 
GeneralRe: C++ : pass a string array to LPARAM Pin
CPallini27-Aug-12 21:10
mveCPallini27-Aug-12 21:10 
GeneralRe: C++ : pass a string array to LPARAM Pin
Atlence28-Aug-12 9:02
Atlence28-Aug-12 9:02 
QuestionRe: C++ : pass a string array to LPARAM Pin
CPallini28-Aug-12 9:59
mveCPallini28-Aug-12 9:59 
AnswerRe: C++ : pass a string array to LPARAM Pin
Atlence28-Aug-12 10:28
Atlence28-Aug-12 10:28 
QuestionRe: C++ : pass a string array to LPARAM Pin
CPallini28-Aug-12 22:58
mveCPallini28-Aug-12 22:58 
AnswerRe: C++ : pass a string array to LPARAM Pin
Atlence29-Aug-12 7:29
Atlence29-Aug-12 7:29 
AnswerRe: C++ : pass a string array to LPARAM Pin
Stefan_Lang27-Aug-12 23:08
Stefan_Lang27-Aug-12 23:08 
Questionhow to send a slider's value while scrolling.? Pin
mbatra3127-Aug-12 2:41
mbatra3127-Aug-12 2:41 
AnswerRe: how to send a slider's value while scrolling.? Pin
Chris Losinger27-Aug-12 3:18
professionalChris Losinger27-Aug-12 3:18 
AnswerRe: how to send a slider's value while scrolling.? Pin
pasztorpisti27-Aug-12 4:27
pasztorpisti27-Aug-12 4:27 
Questionneed help with vector<student*>* students pointer Pin
neodeaths27-Aug-12 0:28
neodeaths27-Aug-12 0:28 
AnswerRe: need help with vector* students pointer Pin
Maximilien27-Aug-12 0:45
Maximilien27-Aug-12 0:45 
There are so many issues with your code ...

Your vector is a pointer; you must allocate it before using it :
The student vector is a member of the class; so you must access it via the school class.

Change to (it is still very early here, and I've noy yet had coffee):
C++
class school
{
public:
  vector<student*> students; // remove the pointer for the vector.

school()
{
  // nothing is really needed in the constructor.
}
}


C++
int main()
{
  student* pStudent = new student; // the vector contains pointers to students; so you need to allocate on the heap.
  school aSchool; // allocated on the stack.
  aSchool.students.push_back( pStudent );

  //...
  
  // don't forget to delete all the allocated student pointers (I'll leave that as an exercise)
  return 0;
}


As a side note, your vector could contain "plain" students if the size and the data inside each student is small and simple enough; that would reduce the need for allocatation and de-allocation.

Also, have a look at smart/shared pointers for cleaner code (more advanced concepts).

Good luck.
Watched code never compiles.

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.