Thread: 'm_dlgColor' : undeclared identifier in B.cpp error....

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    48

    'm_dlgColor' : undeclared identifier in B.cpp error....

    Hey,

    Good day.


    In my project.

    A.h
    Code:
    ...
    
    Public:
    
    COLORREF     m_dlgColor;
    
    ...
    A.cpp
    ......

    B.h
    ...
    B.cpp
    Code:
    #include "A.h"
    
    ...
    
    m_dlgColor = RGB(90,90,90);
    
    ...

    I already declared m_dlgColor as a public propertise. and i also include A.h to my B.cpp.
    Why i can't compile the project successful ?

    Thanks!

    Novice's question. :-)
    Last edited by userpingz; 06-08-2009 at 09:35 PM. Reason: prject -> project
    --------------------------------------------------------
    Newbie
    C/C#/C++
    swimming/cycling/running
    There is nothing more powerful than an idea.
    Except for an idea put into action.
    --------------------------------------------------------

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    A member of a class is just that: a member. It doesn't exist on its own, but only as part of a ... whatever you defined it as part of.

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    48
    As you said,
    Does i should declare "COLORREF m_dlgColor;" at B.h too?

    Suppose, when i changed A.cpp class member - m_dlgColor value to (200, 200, 200). I still want to change B.cpp class member - m_dlgColor value to (200, 200, 200) synchronized.

    Then, how?

    thanks!
    --------------------------------------------------------
    Newbie
    C/C#/C++
    swimming/cycling/running
    There is nothing more powerful than an idea.
    Except for an idea put into action.
    --------------------------------------------------------

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Colour of what?

    You need something like this.
    Code:
    class foo {
    Public:
    
    COLORREF     m_dlgColor;
    };
    And you need an OBJECT instance of some sort

    Code:
    foo aThingamajig;
    before you can do
    Code:
    aThingamajig.m_dlgColor = RGB(90,90,90);
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Let's think about classes again:
    Code:
    class bob {
        public:
            int m_int;
            void bob_function(void);
    };
    Given this class, there is no possible way that "m_int" by itself could ever possibly be correct, except inside the member function bob_function. Everywhere else, it must be object.m_int.

  6. #6
    Registered User
    Join Date
    Mar 2009
    Posts
    48
    i guess i already understand what you said. thanks!
    And furthermore questions.

    A.h
    Code:
    Public:
    COLORREF   m_dlgColor;
    // declare the member at head file.

    A.cpp
    [code]
    class ObjectA {
    public:
    int m_intA;
    // Q1, What's the different Or reason, if i declare member of "m_dlgColor" here ?
    void bob_functionA(void);
    };



    B.h
    Code:
    Public:
    COLORREF   m_dlgColorObjectB;
    B.cpp
    Code:
    class ObjectB {
        public:
            int m_intB;
            void bob_functionB(void);
            {
             // Q2: try to initialization Or Asign value via the following statement ?
             m_dlgColorObjectB = ObjectA.m_dlgColor
            }
            
    };
    Q3. Does the bob_functionB() Could be filled outside of Class ObjectB? What's the different between fill the member function inside the class or outside of the class?

    :-)
    Last edited by userpingz; 06-08-2009 at 09:59 PM. Reason: bold font for the question items
    --------------------------------------------------------
    Newbie
    C/C#/C++
    swimming/cycling/running
    There is nothing more powerful than an idea.
    Except for an idea put into action.
    --------------------------------------------------------

  7. #7
    Registered User
    Join Date
    Mar 2009
    Posts
    48
    Quote Originally Posted by Salem View Post
    Colour of what?
    My windowns forms application skin color changed....
    --------------------------------------------------------
    Newbie
    C/C#/C++
    swimming/cycling/running
    There is nothing more powerful than an idea.
    Except for an idea put into action.
    --------------------------------------------------------

  8. #8
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Neither of your questions make any sense. We declared our ints in the same place, so asking the difference based on where they're located isn't meaningful. And of course you can never assign anything inside a class definition -- you don't have any objects to assign values to. You initialize values in the constructor.

  9. #9
    Registered User
    Join Date
    Mar 2009
    Posts
    48
    Really stupid questions.

    i am appricated for you patient. :-)

    Thanks a lot.
    --------------------------------------------------------
    Newbie
    C/C#/C++
    swimming/cycling/running
    There is nothing more powerful than an idea.
    Except for an idea put into action.
    --------------------------------------------------------

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM
  5. UNICODE and GET_STATE
    By Registered in forum C++ Programming
    Replies: 1
    Last Post: 07-15-2002, 03:23 PM