Git Product home page Git Product logo

learn-c-plus-plus's Introduction


Learning C++

/ISO_C++_Logo.svg

Hello World in C++

#include <iostream>

int main()
{
    std::cout << "Hello, world!\n";
}

This program uses the C++ standard library to write a Hello World program. It is incredibly simple to the syntax of C, the major difference in this example being printf instead being std::cout << (std::cout stands for something, but I can't find info. I think cout stands for C output but I am not sure)

Comments in C++

Comments in C++ are identical to comments in C.

// This is a single line comment
/* This
is a multiline
comment */
/* Multi-line comments
* can also
* be written
* like this */

Break keyword in C++

break;

To this day, I am still not entirely sure what the break keyword does, but most languages support it.

/!\ This example has not been tested yet, and may not work

If/else in C++

x = int(1)
if (x == 0) {
	bool isZeroBool = (true);
} else {
	bool isZeroBool = (false);
}

This is a pretty bad example.

/!\ This example has not been tested yet, and may not work

Classes in C++

One of the major differences between C and C++ is the inclusion of classes. There is a reason why C++ is commonly called C with classes

class superClass() {
	int main() {
		std::cout << "Superclass says: Hello World!";	
	}
	return main();
}

/!\ This example has not been tested yet, and may not work

Booleans in C++

In C++, the Boolean keyword is shortened to bool for this example, I expect you to know the basics of what a Boolean is (a true or false value, yes or no, 1 or 0)

input1 = string(input("Do you think C++ is good? y/N)"));
if input1 == "y" or "Y" {
	bool trueFalse = true;
} else {
	bool trueFalse = false;
}
std::cout << "You entered: " + trueFalse()

/!\ This example has not been tested yet, and may not work

Integers in C++

// This program exponentiates 2 and 16. The result should be 65536
int x = 2;
int y = 16;
cout << x ** y;

/!\ This example has not been tested yet, and may not work

Escape characters in C++

std::cout << "Newline?\nNewline! Tab?\tTab! Quotation Marks?\"Quotation Marks\" ";

/!\ This example has not been tested yet, and may not work

Strings in C++

cpp-with-plus = string("C++");
std::cout << cpp-with-plus;

/!\ This example has not been tested yet, and may not work

Return in C++

class superClass() {
	int main() {
		std::cout << "Superclass says: Hello World!";	
	}
	return main();
	std::cout << "Superclass returned: Superclass says: Hello World!";
}

This example is a slightly modified copy of the class section

/!\ This example has not been tested yet, and may not work

More C++

I have much more to list here, and much to learn.


learn-c-plus-plus's People

Contributors

seanpm2001 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.