Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. typedef struct constructor

typedef struct constructor

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestioncsharpvisual-studio
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    akira32
    wrote on last edited by
    #1

    If I define the constructor of typedef struct, it will appear some error(error C4430,errorC4183). How do I solve this problem?

    struct b
    {

     b() 
     { 
    
     } 
    
     b(int p1) 
     { 
     m\_p1=p1; 
     } 
    
     int m\_p1; 
    

    };

    typedef struct
    {

    a() 
    { 
    
    } 
    
    a(int p1) 
    { 
    	m\_p1=p1; 
    } 
    
    int m\_p1; 
    

    }a;

    1>d:\windowsxpdoc\visual studio 2008\projects\t3\t3\t3dlg.cpp(156) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>d:\windowsxpdoc\visual studio 2008\projects\t3\t3\t3dlg.cpp(158) : warning C4183: 'a': missing return type; assumed to be a member function returning 'int' 1>d:\windowsxpdoc\visual studio 2008\projects\t3\t3\t3dlg.cpp(161) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>d:\windowsxpdoc\visual studio 2008\projects\t3\t3\t3dlg.cpp(163) : warning C4183: 'a': missing return type; assumed to be a member function returning 'int'

    O 1 Reply Last reply
    0
    • A akira32

      If I define the constructor of typedef struct, it will appear some error(error C4430,errorC4183). How do I solve this problem?

      struct b
      {

       b() 
       { 
      
       } 
      
       b(int p1) 
       { 
       m\_p1=p1; 
       } 
      
       int m\_p1; 
      

      };

      typedef struct
      {

      a() 
      { 
      
      } 
      
      a(int p1) 
      { 
      	m\_p1=p1; 
      } 
      
      int m\_p1; 
      

      }a;

      1>d:\windowsxpdoc\visual studio 2008\projects\t3\t3\t3dlg.cpp(156) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>d:\windowsxpdoc\visual studio 2008\projects\t3\t3\t3dlg.cpp(158) : warning C4183: 'a': missing return type; assumed to be a member function returning 'int' 1>d:\windowsxpdoc\visual studio 2008\projects\t3\t3\t3dlg.cpp(161) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>d:\windowsxpdoc\visual studio 2008\projects\t3\t3\t3dlg.cpp(163) : warning C4183: 'a': missing return type; assumed to be a member function returning 'int'

      O Offline
      O Offline
      Ozer Karaagac
      wrote on last edited by
      #2

      the type was named but struct wasn't.

      typedef struct a
      {
      a()
      {
      }

      a(int p1) 
      {
          m\_p1=p1; 
      } 
      
      int m\_p1; 
      

      } aType;

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups