`
ShorenG
  • 浏览: 5182 次
  • 性别: Icon_minigender_1
  • 来自: 火星
最近访客 更多访客>>
社区版块
存档分类
最新评论

C++ Object-Oriented Example

    博客分类:
  • C++
 
阅读更多
 // Main.cpp
  #include <iostream>  //Include 'system'
  #include <cstdlib>
  
  #include "grade_book.h"
  
  using namespace std;

int main(int argc, char **argv)
{
     
	GradeBook myGradeBook;//Warning here!
        //refer to http://stackoverflow.com/questions/4846959/request-for-member-in-which-is-of-non-class-type
 
	cout<<"Welcome to GardeBook for "<<myGradeBook.getCourseName()<<endl;
	
	 system("PAUSE");
	 return 0;
}


  //GrdeBook.h
  #ifndef GRADEBOOK_H
  #define GRADEBOOK_H
  #include <string>
  using namespace std;//'string' type is reside 'std' space
  
  class GradeBook {

public:
		GradeBook();
		~GradeBook();
		void setCourseName(string name);
		string getCourseName();
private:
		string courseName;
};

#endif // GRADEBOOK_H


 //GradeBook.cpp

 #include "grade_book.h"

GradeBook::GradeBook()
{
     courseName = "Jupiter ";       
}

string GradeBook::getCourseName()
{
	return courseName;
}

void GradeBook::setCourseName(string name)
{
	courseName = name;   
}

GradeBook::~GradeBook()
{
}



structure:

  • 大小: 6.1 KB
分享到:
评论

相关推荐

    C++ Object-Oriented Database Generatorc++面向对象的数据库向

    标题中的"C++ Object-Oriented Database Generator"是一个用于创建面向对象数据库的应用程序。这个工具的主要目的是简化C++开发者在处理数据库时的工作,通过提供一种面向对象的方式来操作数据,而不是传统的SQL查询...

    Object- Oriented Programming with Ansi-C

    I had fun discovering that ANSI-C is a full-scale object-oriented language. To share this fun you need to be reasonably fluent in ANSI-C to begin with — feeling comfortable with structures, pointers,...

    Biblio.Distribution.C++.For.Artists.The.Art.Philosophy.and.Science.of.Object-Oriented.Programming.2003.chm

    C++ For Artists: The Art, Philosophy, and Science of Object-Oriented Programming by Rick Miller ISBN:1932504028 Biblio Distribution ? 2003 (590 pages) Intended as both a classroom and reference ...

    Packt.Python.Journey.from.Novice.to.Expert.2016

    It has a practical and example-oriented approach through which both the introductory and the advanced topics are explained. Starting with the fundamentals of programming and Python, it ends by ...

    C++ for Programmers

    PRACTICAL, EXAMPLE-RICH COVERAGE OF: Classes, Objects, Encapsulation, Inheritance, Polymorphism Integrated OOP Case Studies: Time, GradeBook, Employee Industrial-Strength, 95-Page OOD/UML® 2 ATM Case...

    C++四书五经 - 01. TCPL和D&E

    03 Accelerated C++: Practical Programming by Example 04 C++ Primer 05 Essential C++ 3. 高效健壮编程 06 Effective C++: 50 Specific Ways to Improve Your Programs and Design (2nd Edition) 07 More ...

    C++四书五经 - 07. 杂项-02

    03 Accelerated C++: Practical Programming by Example 04 C++ Primer 05 Essential C++ 3. 高效健壮编程 06 Effective C++: 50 Specific Ways to Improve Your Programs and Design (2nd Edition) 07 More ...

    C++四书五经 - 07. 杂项-01

    03 Accelerated C++: Practical Programming by Example 04 C++ Primer 05 Essential C++ 3. 高效健壮编程 06 Effective C++: 50 Specific Ways to Improve Your Programs and Design (2nd Edition) 07 More ...

    C++四书五经 - 05. 标准库

    03 Accelerated C++: Practical Programming by Example 04 C++ Primer 05 Essential C++ 3. 高效健壮编程 06 Effective C++: 50 Specific Ways to Improve Your Programs and Design (2nd Edition) 07 More ...

    C++四书五经 - 03. 高效健壮编程

    03 Accelerated C++: Practical Programming by Example 04 C++ Primer 05 Essential C++ 3. 高效健壮编程 06 Effective C++: 50 Specific Ways to Improve Your Programs and Design (2nd Edition) 07 More ...

    C++四书五经 - 04. 模板和泛型编程

    03 Accelerated C++: Practical Programming by Example 04 C++ Primer 05 Essential C++ 3. 高效健壮编程 06 Effective C++: 50 Specific Ways to Improve Your Programs and Design (2nd Edition) 07 More ...

    C 程序设计教学课件:Chapter 3 class and object.ppt

    Chapter 3 of the C++ programming course delves into the fundamental concepts of object-oriented programming, specifically focusing on classes and objects. Object-oriented programming (OOP) is a ...

    c++ example.rar

    C++的核心特性包括面向对象编程(Object-Oriented Programming, OOP)、模板(Templates)和泛型编程(Generic Programming)、以及底层内存管理。以下是一些C++中的关键知识点: 1. **基础语法**:包括变量声明、...

    《游戏编程精粹》光盘源代码

    《游戏编程精粹》光盘源代码Author: Steve Rabin ... Last revised: 5-20-00 ...to C++ so that it can take advantage of object-oriented techniques (even though it doesn t require them). Good Luck!

    c++基础STL入门ppt课件.ppt

    3. 面向对象(Object-Oriented)的抽象:引入抽象数据类型(ADT,Abstract Data Type),C++的类,将事物的属性与方法紧密地结合在一起。这类抽象可以更好地处理变化,但各个类之间的关系不容易处理。 4. 面向对象...

    Addison.Wesley.C++.by.Dissection.2002.pdf

    Chapter 11 provides a comprehensive view of object-oriented programming (OOP) using C++: - **OOP Language Requirements:** Lists the requirements for an OOP language. - **OOP: The Dominant Programming ...

    Problem Solving with C++ (7th edition)

    This chapter introduces object-oriented programming (OOP) concepts in C++: - **Classes and Objects**: Explanation of classes and objects, including encapsulation, inheritance, and polymorphism. - **...

    ns by example

    NS (version 2) is an object-oriented, discrete event driven network simulator developed at UC Berkely written in C++ and OTcl. NS is primarily useful for simulating local and wide area networks. ...

    Programming Microsoft LINQ in Microsoft.NET Framework 4

    Practical, example-rich coverage of: .NET 4, Types, Arrays, Exception Handling LINQ, Object/Collection Initializers OOP: Classes, Objects, Inheritance, Polymorphism, Interfaces WinForms, WPF, XAML...

Global site tag (gtag.js) - Google Analytics