Unresolved externals error

Hello, I'm currently working on a quick assignment for school to get used to working with classes and constructors, and I had a few things that I wasn't sure about. First off, there are no underlined errors with this code, however when I compile I get the following error:

unresolved external symbol "public_thiscall dog::dog(void)" (??0dog@@QAE@XZ) referenced in function_main

So I assume that the problem is it doesn't like that I called the void dog::dog (which I don't even think exists?)

I've tried poking around for the error, but the error seems to be very broad and case-specific. I did at one point have a void dog::dog, so maybe that has something to do with 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
#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
class dog
{
	private: 
		char dogName[10];
		char dogSays[10];
	public:
		dog();
		void dogz();
		void speak(char name[], char says[]);
};
void dog::dogz()
{
	char name[10];
	char says[10];
	dogName[10] = name[10];
	dogSays[10] = says[10];
	strcpy(name, dogName);
	strcpy(says, dogSays);

}
void dog::speak(char name[], char says[])
{
	cout <<"The dogs name is "<<name<<" and he says "<<says<<endl;
}

void main()
{
	dog stuff;
	stuff.speak("Rover", "Woof");
	getch();
}


Second, the bolded void dog::dogz() part seems weird to me. I don't even know if any of that is doing anything, or if its necessary, but it's in my notes to use it, and making all those arrays and chars and what not was the only way I could figure out how to make the code work (no underlines, that is)

If anyone could maybe point me in the right direction, that'd be great. Thanks in advance!
See this line:
dog();
You promised that you'd write a constructor function dog() that accepted no parameters. If you don't specify any constructors, the compiler will make this default one for you, but since you specified it, you've promised that YOU will write it and the compiler doesn't need to.

Here:
dog stuff;
you tried to use that function. That you promised you would write. But you didn't write it. You broke a promise you made to the compiler.


void main() is wrong. It has never been correct C++. If your compiler doesn't even complain, throw it away and get a C++ compiler.
Last edited on
love the way you worded that. I wrote

1
2
3
dog::dog()
{
}


and all is well! Thank you. is the bolded code all necessary? or can I get rid of some/all of it? I'm going to play around with it a little bit and see what I can do.

thanks again!
A more elegant solution would be to simply remove dog();

is the bolded code all necessary?

Only if you ever want to call the member function dogz.

I'm not kidding about void main().
if I remove dog(); doesn't that make my variable type dog not exist? or does the class dog{} allow you to create variables of type dog?

also, I removed the dogz function because it is indeed useless

edit: nevermind, I don't need dog();.

thanks for the help and little bit of education :)
Last edited on
If you remove dog() and don't provide any other constructors, the compiler makes it for you.
Topic archived. No new replies allowed.