I need help!!!Help me plz

class Math
{

public:
Math();
double LogValue(double, double);
double SineValue(double);
double CosineValue(double);
double TanValue(double);
double CotanValue(double);
int MultiSumFunc(int, int, int);
double GetComplex(int,int,int);

private:

int real,imaginary,a;
double base,value;
double x,y,z,t;
int start,step,upperbound;

};


#include <cstdlib>
#include <iostream>
#include <cmath>
#include "Math.h"

using namespace std;

int main(int argc, char *argv[])
{
Math m;
m.LogValue(10,5);
m.LogValue(2.71,3);
m.LogValue(3,4);
m.SineValue(30);
m.CosineValue(90);
m.TanValue(53);
m.CotanValue(45);
m.MultiSumFunc(3,5,20);
m.Complex(3,4,5);
cout<<"Log value:"<<m.LogValue()<<",Sine Value:"<<m.SineValue()<<endl;
cout<<"Cosine value:"<<m.CosineValue()<<",Tan Value:"<<m.TanValue()<<endl;
cout<<"Cotan value:"<<m.CotanValue()<<",MultiSumFunc Value:"<<m.MultiSumFunc()<<endl;
cout<<"Complex:"<<m.GetComplex()<<endl;

system("PAUSE");
return EXIT_SUCCESS;
}


#include <cstdlib>
#include <iostream>
#include <cmath>
#include "Math.h"

double Math::LogValue(double base,double value)
{
double e=2.71;
if (base==10)
return log10(value);
else if(base==e)
return log(value);
else
return log10(value)/log10(base);
}
double Math::SineValue(double x)
{
return sin(x);
}
double Math::CosineValue(double y)
{
return cos(y);
}
double Math::TanValue(double z)
{
return tan(z);
}
double Math::CotanValue(double t)
{
return 1/tan(t);
}
int MultiSumFunc(int start,int step,int upperbound)
{
int k;
int sum=0;
for(k=start;k<=upperbound;k+=step)
sum+=k;
return sum;
}

double Math::GetComplex(int real,int imaginary,int a)
{
complex mult;
mult.imaginary=imaginary*a.imaginary;
mult.real=real*a.real;
return mult;
}

Where the mistakes? Please hepl me. I'm very desperate with this project:(
Last edited on
Where the mistakes?

Did you try to compile this? The compiler is there to help, it issues message to indicate where and what the problems are.
For example the first message I get is that GetLogValue is not a member of Math.
If you tried to compile this, the compiler should have told you where your errors are.
If you're having trouble understanding the compiler error messages, then you should post those messages and what you don't understand.

PLEASE USE CODE TAGS (the <> formatting button) when posting code. It makes your code easier to read and also makes it easier to respond to your post.

Here the errors I see:
1) In main, you calling a bunch of getter functions, but you have no functions matching those names in your class. i.e. GetLogValue vs. LogValue.

2) #inlude "Math.h" #include is misspelled.

3) return log10(value)/lo10(base); log10 is misspelled.

4) Inconsistency between your delcaration and and implementation for the following: CosineValue/GetCosineValue, TanValue/GetTanValue, CotanValue/GetCotanValue

5) You're using the complex class, but don't include the header. BTW, complex is a template.




Sorry, I made a mistake when I was writing it here.Where the real mistakes? When I compiled this, the messages are: "no matching functions for the call to: LogValue,SineValue,CosineValue..."
This is my homework. I'm the new learning in c++. Also, the lesson is English. My English is not enough. I myself wrote codes, but it is very hard to me complete it.
Where the real mistakes?

I told you where they are.

the messages are: "no matching functions for the call to: LogValue,SineValue,CosineValue..."

I explained that. See #1 and #4.

If you don't understand any part of my explanation, please state what is not clear.

Could you use code tags in order to I can understand it?
Code tags are:
[code]
code here
[/code]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Math
{
public:
Math(); 
double LogValue(double, double);
double SineValue(double);
double CosineValue(double);
double TanValue(double);
double CotanValue(double);
int MultiSumFunc(int, int, int);
double GetComplex(int,int,int);

private:
int real,imaginary,a;
double base,value;
double x,y,z,t;
int start,step,upperbound;
}; 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <cstdlib>
#include <iostream>
#include <cmath>
#include "Math.h"

using namespace std;

int main(int argc, char *argv[])
{
Math m;
m.LogValue(10,5);
m.LogValue(2.71,3);
m.LogValue(3,4);
m.SineValue(30);
m.CosineValue(90);
m.TanValue(53);
m.CotanValue(45);
m.MultiSumFunc(3,5,20);
m.Complex(3,4,5);
cout<<"Log value:"<<m.LogValue()<<",Sine Value:"<<m.SineValue()<<endl;
cout<<"Cosine value:"<<m.CosineValue()<<",Tan Value:"<<m.TanValue()<<endl;
cout<<"Cotan value:"<<m.CotanValue()<<",MultiSumFunc Value:"<<m.MultiSumFunc()<<endl;
cout<<"Complex:"<<m.GetComplex()<<endl;

system("PAUSE");
return EXIT_SUCCESS;
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <cstdlib>
#include <iostream>
#include <cmath>
#include "Math.h"

double Math::LogValue(double base,double value)
{ 
double e=2.71;
if (base==10)
return log10(value);
else if(base==e)
return log(value);
else
return log10(value)/log10(base);
}
double Math::SineValue(double x)
{
return sin(x);
}
double Math::CosineValue(double y)
{
return cos(y);
}
double Math::TanValue(double z)
{ 
return tan(z);
}
double Math::CotanValue(double t)
{
return 1/tan(t);
}
int MultiSumFunc(int start,int step,int upperbound)
{ 
int k;
int sum=0;
for(k=start;k<=upperbound;k+=step)
sum+=k;
return sum;
}

double Math::GetComplex(int real,int imaginary,int a)
{
complex mult;
mult.imaginary=imaginary*a.imaginary;
mult.real=real*a.real;
return mult;
}



Please explain the mistakes with codes in order to I can understand it? I cannot still find it.
math.h line 11
 
double GetComplex(int,int,int);


main.cpp line 19
 
m.Complex(3,4,5);

GetComplex and Complex are different names.

main.cpp line 20:
 
cout<<"Log value:"<<m.LogValue()<<",Sine Value:"<<m.SineValue()<<endl;

m.LogValue() function requires two arguments.
m.SineValue() function requires 1 argument.

Line 21, Same problem with m.CosineValue() and m.TanValue().
Line 22, Same problem with m.CotanValue() and m.MultiSumFunc()
Line 23, Same problem with m.GetComplex()


How can I write them correctly?

1
2
3
4
5
6
7
cout<<"Log value:"<<m.LogValue()<<endl;
cout<<"Sine value:"<<m.SineValue()<<endl;
cout<<"Cosine value:"<<m.CosineValue()<<endl;
cout<<"Tan value:"<<m.TanValue()<<endl;
cout<<"Cotan value:"<<m.CotanValue()<<endl;
cout<<"MultiSumFunc Value:"<<m.MultiSumFunc()<<endl;
cout<<"Complex:"<<m.GetComplex()<<endl;


Is it true?
Last edited on
That didn't change anything.

You have a couple of options:
1) You could pass arguments to the m.LogValue() function:
 
cout<<"Log value:"<<m.LogValue(10,5)<<endl;


Or, 2) You could save the values you're calculating and then output those:
1
2
3
4
double logval1;
logval1 = m.LogValue(10,5);
...
cout<<"Log value:"<< logval1 <<endl;



Thank you so much for your replies.
Topic archived. No new replies allowed.