hi,
please helpe me my code include one problem and i dont know how to slovet
the heder

#ifndef COURSE_H_
#define COURSE_H_

#include <iostream>
using namespace std;

#include<string>
using namespace std;
class Course

{
private:

string id;

int NumberOfCredits;

static string serialId;



public:


Course(string corsename)
{

}

void print()
{
	
}
};
#endif/*COURSE_H_*/

the.cpp

#include"a.h"




 int serialId=001;

 Course::Course(int numberofcridet)
{
	NumberOfCredits=numberofcridet;

    serialId++;
	std::stringstream ss;
	ss <<Cs <<ID;
	id= ss.str();


}

	   

	   
	   

void Course::print()
{
	cout<<"The name of course is:\n"<<corsename;
	cout<<"The Id of course is:\n"<<id;
		cout<<"The number of cridet is:"<<numberofcredits<<endl;
}

the main

#include"a.h"
int main()
{

Course CourseObj(4);
CourseObj.print();
return 0;
}

i hope helpe me:(

-------------------
Compiling...
amain.cpp
c:\course new\amain.cpp(6) : error C2664: '__thiscall Course::Course(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)' : cannot convert parameter 1 from 'const int' to 'class std::basic_string<char,struct std:
:char_traits<char>,class std::allocator<char> >'
No constructor could take the source type, or constructor overload resolution was ambiguous
Error executing cl.exe.

amain.obj - 1 error(s), 0 warning(s)

Instead of declaring the functions in the header as "void print(){}", you need "void print();". The same applies to the constructor.

Also, you've declared the constructor to take in a string, but you implemented it to take an int in your .cpp file. You need to be consistent.

There is more than one error in the program. The one you have been informed of first involves the constructor you have written.

In the .h file file you declare the constructor taking a string:

Course(string corsename)

and you define it inline by placing the {} after the above line instead of a semicolon.

Then in the .cpp file you define a constructor whose first line is this:

Course::Course(int numberofcridet)

There is no constructor in the .h file that takes an int object as a parameter. The only constructor you have declared takes a string object. Therefore this is an error. The parameters the constructor takes must match in both files. And don't use the {} after the declaration in the .h file if you are going to define the function/constructor in the .cpp file.

tanks for all

can you write the coorect in my code

becuse i dont speak english well

pleeeas

pleas i need the correct code because i must
give the my teatcher tomorw

Simple class without inclusion gaurds demonstrating default and nondefault constructors and class methods.

//////////
////A.h
class A
{
    private:
       int data;
    public:
       A();
       A(int);
       void setData(int);
};

///////////
//A.cpp 

#include "A.h"

//default constructor 
//sets data to default value of zero using initializer list
A::A() : data(0)
{} 

//non-default constructor
//sets data to input i using initializer list
A::A(int i) : data(i)
{}

//member function, aka method
void A::setData(int i)
{
   data = i;
}

If you follow the above example, modified to your code, it should work ok.

lerner why dont correct my code

i change code and the broblem wile stile

the header

#ifndef COURSE_H_
#define COURSE_H_

#include <iostream>
using namespace std;

#include<string>
using namespace std;
class Course

{
private:

string id;

int NumberOfCredits;

static string serialId;



public:


Course(string corsename);




void print()
{

}
};
#endif/*COURSE_H_*/

the .cpp

#include"a.h"




 int serialId=001;

 Course::Course(int string corsename)
{
    NumberOfCredits=numberofcridet;

    serialId++;
    std::stringstream ss;
    ss <<Cs <<ID;
    id= ss.str();


}






void Course::print()
{

    cout<<"The Id of course is:\n"<<id;

}

the main

#include"a.h"
int main()
{
int n;
Course CourseObj("Cs");
cout<<"Enter number of cridet:";
cin>>n;
cout<<"The number of cridet is:"<<n<<endl;
CourseObj.print();
return 0;
}

thankyou leaner for help me

You haven't followed the advice provided or the example posted. Notice how both the declaration of the nondefault constructor for class A in the A.h file and in the definition of the nondefault constructor in the A.cpp have the same variable type passed to them. You need to do the same in files. Pure and simple. No reason for me or any one else to do it for you. Don't expect code you can cut and paste from an answer into your program. Expect discussions, examples, etc that can be used to correct your code.

ok leaner

i make all to say me
but
the code include error

the error massege

-------------------Configuration: main - Win32 Debug--------------------
Compiling...
main.cpp
Linking...
main.obj : error LNK2001: unresolved external symbol "public: void __thiscall Course::print(void)" (?print@Course@@QAEXXZ)
main.obj : error LNK2001: unresolved external symbol "public: __thiscall Course::Course(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (??0Course@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator
@D@2@@std@@H@Z)
Debug/main.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

main.exe - 3 error(s), 0 warning(s)

what the meaning thise error??

It means the software trying to convert your program into a form that the computer can use can't find something you are trying to use. Often it means you call a function that hasn't been declared yet or defined yet. Frequently, it occurs when you misspell something when writing the function code or try to send parameters to a function that don't match the expected parameters in terms of number or type, etc. In this case, it looks like something in the print() function isn't matching up.

oh my gad

i dont understand english iam from Astralia

pleas how to slove this brobleam

leaner iam very sad whats the error in my code?????????????????????????????

Post your latest version of the code. I have to sign off for a while but maybe will find time to log back on later. Otherwise someone else should be around to help, but they aren't likely to hand you valid code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.