Example of creating a Class project using Dev-C ++

Source: Internet
Author: User

Open Dev-C ++ and follow the steps below to create a Project: File-> New-> Project. The following window is displayed: select Console Application (if you want to create a GUI program, select Windows Application) and create a new file (Ctrl + n ), be sure to select Add to project (you can select Yes in the following window); otherwise, compilation will fail (Link error, I tried ). Generally, if a project has a class, it should have at least main. cpp and xxx. cpp and xxx. h among the three files, xxx is the class file name. My file is as follows: main. cpp [cpp] // main. cpp # include <iostream> # include "demo. h "/* run this program using the console pauser or add your own getch, system (" pause ") or input loop */int main (int argc, char * argv []) {demo foo1 (0); foo1.show (); return 1 ;}demo. h [cpp] // demo. h # ifndef DEMO_H _ # define DEMO_H _ class demo {private: int var1; public: demo (); Demo (int );~ Demo (); void show () ;};# endif demo. cpp [cpp] // demo. cpp # include <iostream> # include "demo. h "// constructors demo: demo () {var1 = 0x101; std: cout <" var1 = "<var1 <std: endl ;} demo: demo (int input) {this-> var1 = input;} void demo: show () {std: cout <"I am human being, you are computer ~~ \ N "<std: endl; if (0 = this-> var1) {std: cout <" error "<std: endl ;} else std: cout <"right" <std: endl; return;} demo ::~ Demo (){}

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.