namespace and class..help!

This is a discussion on namespace and class..help! within the C++ Programming forums, part of the General Programming Boards category; this is my CDlg32.cpp Code: #include <windows.h> #include "CDlg32.h" namespace Joel { class CDlg32 { private: HINSTANCE hInstancia; HWND hDlg; ...

  1. #1
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    307

    namespace and class..help!

    this is my CDlg32.cpp
    Code:
    #include <windows.h>
    #include "CDlg32.h"
    
    namespace Joel {
    	class CDlg32 {
    	private:
    		HINSTANCE hInstancia;
    		HWND hDlg;
    		int nDLG;
    	public:
    		CDlg32();
    		~CDlg32();
    	protected:
    	};
    }
    Now, CDlg32.h:
    Code:
    #if !defined(_CDLG32_H)
    #define _CDLG32_H
    
    CDlg32::CDlg32() : hInstancia(NULL), hDlg(NULL), nDLG(0) {}
    
    #endif
    Now main.cpp
    Code:
    #include <windows.h>
    #include "CDlg32.h"
    
    using Joel::CDlg32;
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {
    	return 0;
    }
    Returns this errors.
    CDlg32.h(4) : error C2871: 'Joel' : does not exist or is not a namespace
    CDlg32.h(6) : error C2653: 'CDlg32' : is not a class or namespace name
    CDlg32.h(6) : error C2550: 'CDlg32' : constructor initializer lists are only allowed on constructor definitions
    CDlg32.h(6) : warning C4508: 'CDlg32' : function should return a value; 'void' return type assumed
    main.cpp(4) : error C2653: 'Joel' : is not a class or namespace name
    main.cpp(4) : error C2873: 'CDlg32' : symbol cannot be used in a using-declaration
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,973
    It looks like the code in CDlg32.cpp should be in CDlg32.h
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,424
    And code that is in the CDlg32.h should be in the cpp
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  4. #4
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    307
    Yeah!

    Didn't see that!

    Thanks!
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with friend class declaration in a namespace
    By Angus in forum C++ Programming
    Replies: 2
    Last Post: 12-09-2008, 12:29 PM
  2. inline templated class method as standalone function in namespace
    By monikersupreme in forum C++ Programming
    Replies: 4
    Last Post: 10-28-2008, 11:38 AM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 10:03 PM
  4. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  5. Predeclaration of template class in namespace
    By unregistred in forum C++ Programming
    Replies: 0
    Last Post: 05-30-2003, 03:52 AM

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