GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — learn/doc/cpp_type_variable at main · gyuho/learn

Expand file tree

/

cpp_type_variable

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

cpp_type_variable

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
code
code
 
 
README.md
README.md
 
 

README.md

Outline

back to contents

C++: type, variable

  • type
  • variable

↑ top




type

  • C++ type system

↑ top




variable

/*
g++ -std=c++11 00_variable.cpp -o 00_variable;
./00_variable;
*/
#include <iostream>
using namespace std;

int main()
{
	// declaring variables:
	int a, b;

	a = 7;
	b = 2;
	a = a + 1;
	b++;
	auto c = a - b;
	// int c = a - b;
	cout << c << endl;
	// 5

	string st1("Hello");
	cout << st1 << endl;
	// Hello

	string st2 = "World";
	cout << st2 << endl;
	// World

	return 0;
}

According to FAQ , return 0; is not needed:

In C++, main() need not contain an explicit return statement. In that case, the value returned is 0, meaning successful execution.

#include <iostream>

int main()
{
	std::cout << "This program returns the integer value 0\n";
}

↑ top




You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.