visual studio - "type 'int' unexpected" in constructor, Can't find WHY? -


i'm quite new c++ , syntax. have programmed in c# before, thought give c++ try.

i created classlibrary in visual studio , want add classes it. know managed c++.

but can't wrap head around why keep getting these errors:

error c2062: type 'int' unexpected error c2143: syntax error: messing ; before '{' error c2447: '{' : missing function header (old-style formal list?) 

this header file:

// librarylib.h  #pragma once #include <string> using namespace system;  namespace librarylib {  public enum entrytype {book, newspaper};  public ref class entry {    public:     int id;     int year;     string ^ title;     entrytype type;      entry(int id, int year, string ^ title, entrytype type);  }; } 

this cpp file:

// main dll file.  #include "stdafx.h" #include "librarylib.h"  namespace librarylib {  librarylib::entry(int id, int year, string ^ title, entrytype type) // line of errors    {     id = id;     year = year;     title = title;     type = type; } } 

the 3 errors thrown on line want implement constructor in cpp file.

i hope 1 can point me out i'm doing wrong.

thanks!

you aren't qualifying constructor right. need entry:: in there:

entry::entry(int id, int year, string ^ title, entrytype type) 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -