Software Test Job 1--problems and solutions to the mutual invocation of classes in C + + projects

Source: Internet
Author: User

In the C + + course of the semester, the teacher left three major projects and some small homework, these projects for me is very meaningful,

It is a pleasure to constantly improve the programming ability in the process of completing the homework, every homework has a lot of small problems,

Either there is a problem with the compilation, either a dead loop occurs directly after the program runs, or because the pointer problem program is all out of the card, you need to

Every possible error in the program before and after the test output to see where the program is wrong, so it is very important to learn how to test, it is often possible to do more with less.

What is particularly profound is that in the process of completing an implementation of the JSON entity class in C + +, we have encountered the challenge of calling each other class, and have spent a certain amount of time.

(JSON entity class object and value class value, array class, the approximate variable definition declaration of the class is array:vector<value>;   Value:int, Double,array; Object:map<string,value>)

At first, the job was to implement three classes in a. cpp file and found that there was a problem after writing the various function declarations for the class (because the class calls each other so

Compile error is the value class is not declared such as), try to search the solution on the Internet, and then combine the understanding of C + + class, so find a solution, in the program's most

Before starting the implementation of the class, add three simple declarations class Array, class Object, Class Value, and the program is finally compiled.

And then due to the need for program normalization, I took three classes to separate the write, so for each class is defined by the. cpp and. h files, in these files the mutual invocation of the class

has become a very difficult problem, according to the previous experience in a CPP, I first in each class of. h file added to remove the class of the other need to call the class

statement, and then follow the previous experience, such as adding the header file include "Array.h" to the Array.cpp, to find that the compilation does not pass, and finally in Array.cpp

Add the. h file of the class that needs to be called, and the final compilation passes.

Software Test Job 1--problems and solutions to the mutual invocation of classes in C + + projects

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.