Parent directory
Makefile
hello.cpp
CC = g++
CXX = g++
CFLAGS = -g -Wall
CXXFLAGS = -g -Wall -std=c++17
hello: hello.o
hello.o: hello.cpp
.PHONY: clean
clean:
rm -f *.o hello
.PHONY: all
all: clean hello
#include <iostream>
namespace c2cpp {
int main()
{
using namespace std;
// Subtle diff between "=" and "{}" styles of initialization
//
// int x = 5.7; cout << x << endl; // x is 5
// int x {5.7}; // error: narrowing coversion
// Different syntax for object initialization
//
// std::string s("hello ");
// std::string s = "hello ";
// std::string s = {"hello "};
// std::string s {"hello "};
std::string s;
// s = "hello " + "whole "; // error
// You can change the above line to the following:
// s = "hello ";
// s = s + "whole ";
// s = s + 100; // error
// s += 101; // s += 'e';
// s += 1101; // cryptic warning...
// std::cout << "hello " << 4995 << "\n" << std::flush;
cout << s << "world " << 4995 << endl;
return 0;
}
}
int main()
{
return c2cpp::main();
}