Build Error because of a Member Function

Sep 8, 2010 at 1:21pm
Good Day! My C++ project seems to have an error when it builds and I kindly ask for help. My program basically multiplies and adds either positive or negative really large integers.
My program seems okay to me but it doesn't build.
I think it is due to my equalizeLength(); function but I'm not really sure.

The dev C++ compiler tells me:
line 77 VVLIver1.cpp: default argument given for parameter 3 of 'void VVLI::equalizeLength(std::string&, std::string&, char)'
line 28 VVLIver1.h: after previous specification in 'void VVLI::equalizeLength(std::string&, std::string&, char)'
[Build Error] [VVLIver1.o] Error 1

VVLIver1.h File
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
#ifndef VeryLINT_H
#define VeryLINT_H 1
#include <iostream>
#include <string>
#include <stack>

using namespace std;

class VVLI
{
      private:
              
             string num;    
      public:                       

             VVLI(string s);
             VVLI();
             
             void negativeop(string num1, string num2);
             void deleteneg(string& num);
             void deleteLeadingZeros(string& num);
             void equalizeLength(string& num1 , string& num2, char pad = '0');
             string addLargeNumbers(string num1, string num2);
             string subtractLargeNumbers(string num1, string num2);
             void addOp(string num1, string num2);
             string multiplyLargeNumbers(string num1, string num2);
             void multiplyOp(string num1, string num2);
             
             friend istream& operator >>(istream& in, VVLI& INT);
             friend ostream& operator <<(ostream& out, VVLI& INT);
             VVLI operator + (VVLI& INT);
             VVLI operator * (VVLI& INT);
};


#endif 



VVLIver1.cpp File Just a Snippet. Not the full code.
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <iostream>
#include <string>
#include <stack>
#include <cstdlib>
#include "VVLIver1.h"

using namespace std;



void VVLI::equalizeLength(string& num1 , string& num2, char pad = '0')
{

	if(num1.size() < num2.size()){
		unsigned int diff = num2.size() - num1.size();
		string temp;
		while(diff--) //add starting zeros
			temp += pad;
		temp += num1;
		num1 = temp;
	}
	else if(num2.size() < num1.size()){
		unsigned int diff = num1.size() - num2.size();
		string temp;
		while(diff--) //add starting zeros
			temp += pad;
		temp += num2;
		num2 = temp;
	}
}






VVLI VVLI::operator +(VVLI& INT)
{
     equalizeLength(num,INT.num);
    
     short numb1 = (num[0] - '0'), numb2 = (INT.num[0] - '0');
     string num1 = addLargeNumbers(num,INT.num);
     string num2 = subtractLargeNumbers(num,INT.num);
     
     if( negfuncnum1 == true && negfuncnum2 == true)
     {
         //cout << "-" << addLargeNumbers(num1, num2) << endl;
         num1.insert(0, "-"); VVLI a(num1); return a;
     }
     if( numb1 >= numb2 && negfuncnum1 != true && negfuncnum2 == true)
     {
         //cout << subtractLargeNumbers(num1, num2) << endl;
         VVLI b(num2); return b;
     }
     if( numb1 >= numb2 && negfuncnum1 == true && negfuncnum2 != true)
     {
         //cout << "-" << subtractLargeNumbers(num1, num2) << endl;
         num2.insert(0, "-"); VVLI b(num2); return b;
     }
     if( negfuncnum1 != true && negfuncnum2 != true)
     {
         //cout << addLargeNumbers(num1, num2) << endl;
         VVLI a(num1); return a;
     }
     
     
     if( numb1 <= numb2 && negfuncnum1 != true && negfuncnum2 == true)
     {
         //cout << "-" << subtractLargeNumbers(num1, num2) << endl;
         num2.insert(0, "-"); VVLI b(num2); return b;
     }
     if( numb1 <= numb2 && negfuncnum1 == true && negfuncnum2 != true)
     {
         //cout << subtractLargeNumbers(num1, num2) << endl;
         VVLI b(num2); return b;
     }
       

}


Thank you!!! I hope that someone may enlighten me. It would be really nice if someone can explain why my program doesn't work.
Sep 8, 2010 at 1:31pm
On line 11 of VVLIver1.cpp, just remove the default value part (= '0'). I haven't really taken a close look but that's what the compiler error message is about.
Last edited on Sep 8, 2010 at 1:32pm
Topic archived. No new replies allowed.