No matching function for custom class

In this scheduling program, I am trying to use my class as a data type, but my compiler seems to be interpreting my constructor as a member function, since I get ObjecktApp.cpp no matching function for call to `swirly_objeckt::objeckt::objeckt()' after I attempt to use the class as a data type. I am using dev and visual 2010 express. I would appreciate any help at all. Thanks!

The variable-type date is from another project, I don't think it is relevant, but if needed I will gladly post it.

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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//Header file
#ifndef OBJECKT
#define OBJECKT
#include <string>
#include "date.h" //This is 

//using namespace swirly_D;
namespace swirly_objeckt
{
	class objeckt
	{
	public:
		objeckt(std::string name, std::string descrip, int category, int   priority,float prog, /*date begin=date(), date due=date(), */
				float timeNeeded=10/*string res[15],*/);
		std::string nameC(std::string input);
		std::string desC(std::string input);

		std::string get_name()const{return name;}
		std::string get_descrip()const{return descrip;}
		

		void set_name();
		void set_descrip();
		

	private:
		
			std::string name;//a
			std::string descrip;//b
	};

}

#endif

//implementation file
#include "Objeckt.h"
#include "date.h"
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
using namespace std;
using namespace swirly_D;

/*To do
find where 
xx=yy
xy=something(error 2039)
no constructor?


*/

namespace swirly_objeckt
{
objeckt::objeckt(std::string name, std::string descrip, int category, int priority, float timeNeeded, float prog )
{
	//std::string strcpy( std::string name,"name");
	name ="name";
	//std::string strcpy (std::string descrip, "Description");
	descrip = "Description";
	category;
	priority =0;
	timeNeeded=10;
	prog;
}

std::string objeckt::nameC(std::string input/*,std::string name*/)
{
	std::string strcpy(name,input);
	return name;
}

std::string objeckt::desC(std::string input/*, std::string descrip*/)
{
	std::string strcpy(descrip,input);
	return descrip;
}
//similar functions
}

//application file
#include <iostream>
#include <fstream>
#include <cstdlib>
#include "Objeckt.h"
using namespace std;
using namespace swirly_objeckt;

int main()
{
	objeckt o1;// Error here is: ObjecktApp.cpp no matching function for call to            //`swirly_objeckt::objeckt::objeckt()'
	int choice, menu;
	ofstream outFile;

	cin>>choice;
	switch(menu)
	{
	case 1:
		{
		switch (choice)
		{
		case 1:
			{
			string input;
			cout<<"Enter the new name of the objective"<<endl;
			cin>>input;
			o1.nameC(input);
			break;//I have several more functions in this format
			}//one for each variable in the constructor
		
		break;
		}
		}
	return 0;
}
}


Edit: Thanks that was hugely helpful!
Last edited on
Because you defined a constructor, the compiler no longer gives you a default constructor, however you are attempting to default construct an instance of objeckt on the error line.
Thanks - I understand what I did wrong, but not how to fix it. Do I need to create another function with no values to act as the default constructor?
Well, either you intended to use the constructor you wrote or not. If you intended to use it, then you would only instantiate objeckt once you have all the parameters. If you didn't intend to use it, then just remove your constructor and the problem will go away.
Topic archived. No new replies allowed.