The vc Code cannot be switched to linux.

Source: Internet
Author: User
The vc Code cannot be switched to linux. -- Linux general technology-Linux programming and kernel information. The following is a detailed description. Hello everyone, I am posting here for the first time, so I have no scores. Please take a look at the following questions.
This is a piece of code I wrote under VC. It can run normally under VC, but it becomes a problem when I move to linux.
Main, cpp:

# Include
# Include
Using namespace std;


# Include "anminial. h"
# Include "dog. h"
# Include "cat. h"

Class Dog;
Class Cat;

Void soundPlay (Anminial & A1, Anminial & A2)
{

}
Void soundPlay (Anminial * A1, Anminial * A2)
{
A1-> sound ();
A2-> sound ();
}


Int main ()
{
// Anminial * anminial = new Anminial ();
// Dog * dog = new Dog ("aa", 11 );
// Cat * cat = new Cat ("bb", 12 );
Dog dog;
Cat cat;

// Anminial-> run ();
Dog. run ();
Cat. run ();
Cout <"*********************************" <
// Anminial-> sound ();
Dog. sound ();
Cat. sound ();
Cout <"*********************************" <
// Anminial = dog;
// Anminial. run ();
// Anminial = cat;
// Anminial. run ();
// Cout <"********************************** "<
// Dog = cat; // Lu ?? Halogen ?? Mao
// Dog-> run ();
// Cout <"********************************** "<
SoundPlay (& dog, & cat );
Cout <"*********************************" <
SoundPlay (cat, dog );
Cout <"*********************************" <
Return 0;
}

Cat. h:
# Ifndef _ cat1_h _
# Define _ cat1_h _

// # Include "stdafx. h"
# Include "anminial. h"

# Include
Using namespace std;

Class Cat: public Anminial
{
Public:
Cat ();
Cat (string name, int weight );

~ Cat ();

Void sound ();
Void run ();
};
# Endif

Cat. cpp:
# Include "cat. h"
# Include "animial. h"
// # Include "anminial. h"
# Include
Using namespace std;

Cat: Cat ()
: Anminial ()
{
This-> name = "";
This-> weight = 11;
}

Cat: Cat (string name, int weight)
: Anminial (name, weight)
{
This-> name = name;
This-> weight = weight;
}

Void Cat: run ()
{
Cout <"cat is runnint" < }

Void Cat: sound ()
{
Cout <"cat is miaoing" < }
There is also a dog class, which is similar to cat and won't be written here,
In linux, many problems have occurred, most of which have been solved, but the following errors have not been found out for two days. Let's see what the problem is.
It seems that an error occurred during the connection. After searching, the general cause is that the implementation of this function cannot be found. But I don't know how to solve it.
Main. o (. text + 0x40): In function 'main ':
/Home/wanglei/test2/main. c: 31: undefined reference to 'dog: Dog [in-charge] ()'
Main. o (. text + 0x4b):/home/wanglei/test2/main. c: 32: undefined reference to 'cat: Cat [in-charge] ()'
Main. o (. text + 0x53):/home/wanglei/test2/main. c: 35: undefined reference to 'dog: run ()'
Main. o (. text + 0x5b):/home/wanglei/test2/main. c: 36: undefined reference to 'cat: run ()'
Main. o (. text + 0x85):/home/wanglei/test2/main. c: 40: undefined reference to 'dog: sound ()'
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.