Initializing

This is a discussion on Initializing within the C++ Programming forums, part of the General Programming Boards category; How exactly are you supposed to initialize a class variable? I attached my file for you to look at and ...

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    4

    Initializing

    How exactly are you supposed to initialize a class variable? I attached my file for you to look at and the error message.


    ------ Rebuild All started: Project: TTSOutgoing, Configuration: Debug Win32 ------

    Deleting intermediate files and output files for project 'TTSOutgoing', configuration 'Debug|Win32'.
    Compiling...
    TTSOutgoing.cpp
    c:\program files\speechstudio\samples\vcpp\ttsoutgoing\ttsout going.cpp(320) : warning C4700: local variable 'pCallStateEvent' used without having been initialized
    Compiling resources...
    Linking...

    Build log was saved at "file://c:\Program Files\SpeechStudio\Samples\VCpp\TTSOutgoing\Debug\ BuildLog.htm"
    TTSOutgoing - 0 error(s), 1 warning(s)
    Attached Files Attached Files

  2. #2
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    Try new'ing the object.

    pCallStateEvent = new /*Place Class/Struct name here*/;

  3. #3
    Registered User
    Join Date
    Jul 2002
    Posts
    4
    I'm not exactly sure how you would do that since I'm a newbie. How would you do that at around line 316? Could you show me an example.

  4. #4
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    Let's say I had an object/struct called DOG.

    Now I declare a pointer to DOG.
    Code:
    DOG* busta;
    Now before I can use busta, I have to create it.
    Code:
    busta = new DOG;
    It shouldn't be too hard to figure out.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  2. Array initializing to a function parameter
    By JulleH in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2005, 07:56 AM
  3. Initializing and Solving matrices
    By scottmanc in forum C++ Programming
    Replies: 1
    Last Post: 11-16-2003, 04:06 PM
  4. Initializing array and non-standard constructor
    By Jasel in forum C++ Programming
    Replies: 15
    Last Post: 11-10-2003, 02:56 PM
  5. initializing hex?
    By keithmolo in forum C++ Programming
    Replies: 4
    Last Post: 08-13-2003, 09:34 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21