root@kali:~# cd Documents/cpp/week3
root@kali:~/Documents/cpp/week3# g++ 1.cpp
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
root@kali:~/Documents/cpp/week3# g++ 1.cpp
1.cpp: In member function ‘int Test::change(int) const’:
1.cpp:10:7: error: assignment of member ‘Test::i’ in read-only object
i = k
^
1.cpp:11:3: error: expected ‘;’ before ‘return’
return i;
^~~~~~
1.cpp: At global scope:
1.cpp:15:11: error: ‘::main’ must return ‘int’
void main(){
^
root@kali:~/Documents/cpp/week3# g++ 1.cpp
1.cpp: In member function ‘int Test::change(int) const’:
1.cpp:10:7: error: assignment of member ‘Test::i’ in read-only object
i = k;
^
1.cpp: At global scope:
1.cpp:15:11: error: ‘::main’ must return ‘int’
void main(){
^
root@kali:~/Documents/cpp/week3# g++ 1.cpp
1.cpp: In member function ‘int Test::change(int) const’:
1.cpp:10:7: error: assignment of member ‘Test::i’ in read-only object
i = k;
^
root@kali:~/Documents/cpp/week3# g++ 1.cpp
1.cpp: In member function ‘int Test::change(int) const’:
1.cpp:10:7: error: assignment of member ‘Test::i’ in read-only object
i = k;
^
root@kali:~/Documents/cpp/week3# g++ 1.cpp
root@kali:~/Documents/cpp/week3# ./a.out
5root@kali:~/Documents/cpp/week3# ./a.out
5root@kali:~/Documents/cpp/week3# g++ 1.cpp
root@kali:~/Documents/cpp/week3# ./a.out
5root@kali:~/Documents/cpp/week3# ./a.out
5root@kali:~/Documents/cpp/week3# g++ 1.cpp
root@kali:~/Documents/cpp/week3# ./a.out
6root@kali:~/Documents/cpp/week3# g++ 1.cpp
root@kali:~/Documents/cpp/week3# ./a.out
6root@kali:~/Documents/cpp/week3# g++ 1.cpp
root@kali:~/Documents/cpp/week3# ./a.out
6
root@kali:~/Documents/cpp/week3# g++ 1.cpp
root@kali:~/Documents/cpp/week3# ./a.out
6
root@kali:~/Documents/cpp/week3# g++ 1.cpp
root@kali:~/Documents/cpp/week3# ./a.out
6
6root@kali:~/Documents/cpp/week3# g++ 1.cpp
1.cpp: In member function ‘int Test::change(int&, int)’:
1.cpp:12:4: error: increment of read-only parameter ‘x’
x++;
^~
root@kali:~/Documents/cpp/week3# ./a.out
6
6root@kali:~/Documents/cpp/week3# g++ 1.cpp
1.cpp:5:1: error: expected unqualified-id before ‘{’ token
{
^
1.cpp: In function ‘int main()’:
1.cpp:18:7: error: aggregate ‘Test t1’ has incomplete type and cannot be defined
Test t1;
^~
root@kali:~/Documents/cpp/week3# g++ 1.cpp
1.cpp:4:7: error: expected identifier before ‘const’
class const Test
^~~~~
1.cpp:6:2: error: expected primary-expression before ‘int’
int i = 5;
^~~
1.cpp:6:2: error: expected ‘}’ before ‘int’
1.cpp:7:1: error: expected unqualified-id before ‘public’
public:
^~~~~~
1.cpp:15:1: error: expected declaration before ‘}’ token
};
^
root@kali:~/Documents/cpp/week3# v
bash: v: command not found
root@kali:~/Documents/cpp/week3# version
bash: version: command not found
root@kali:~/Documents/cpp/week3# --version
bash: --version: command not found
root@kali:~/Documents/cpp/week3# ls
1.cpp a.out
root@kali:~/Documents/cpp/week3# sl
bash: sl: command not found
root@kali:~/Documents/cpp/week3# ls
1.cpp a.out
root@kali:~/Documents/cpp/week3# g++ 1.cpp
1.cpp: In function ‘int main()’:
1.cpp:20:21: error: passing ‘const Test’ as ‘this’ argument discards qualifiers [-fpermissive]
cout<<t1.change(t,t)<<endl;
^
1.cpp:8:6: note: in call to ‘int Test::change(int&, int)’
int change(int &k, int x)
^~~~~~
root@kali:~/Documents/cpp/week3# g++ 1.cpp
root@kali:~/Documents/cpp/week3# ./a.out
7
7root@kali:~/Documents/cpp/week3# g++ 1.cpp
root@kali:~/Documents/cpp/week3# ./a.out
7
7root@kali:~/Documents/cpp/week3# g++ 1.cpp
1.cpp: In member function ‘int Test::change(int&, int) const’:
1.cpp:10:7: error: assignment of member ‘Test::i’ in read-only object
i = k;
^
root@kali:~/Documents/cpp/week3# g++ 1.cpp
1.cpp: In member function ‘int Test::change(int&, int) const’:
1.cpp:10:7: error: assignment of member ‘Test::i’ in read-only object
i = k;
^
root@kali:~/Documents/cpp/week3# g++ 1.cpp
root@kali:~/Documents/cpp/week3# g++ 2.cpp
2.cpp:7:16: warning: character constant too long for its type
istream ifile('text.txt');
^~~~~~~~~~
2.cpp: In function ‘int main()’:
2.cpp:7:26: error: invalid conversion from ‘int’ to ‘std::basic_istream<char>::__streambuf_type* {aka std::basic_streambuf<char>*}’ [-fpermissive]
istream ifile('text.txt');
^
In file included from /usr/include/c++/7/iostream:40:0,
from 2.cpp:1:
/usr/include/c++/7/istream:93:7: note: initializing argument 1 of ‘std::basic_istream<_CharT, _Traits>::basic_istream(std::basic_istream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>]’
basic_istream(__streambuf_type* __sb)
^~~~~~~~~~~~~
root@kali:~/Documents/cpp/week3# g++ 2.cpp
2.cpp:7:17: warning: character constant too long for its type
ifstream ifile('text.txt');
^~~~~~~~~~
2.cpp: In function ‘int main()’:
2.cpp:7:16: error: variable ‘std::ifstream ifile’ has initializer but incomplete type
ifstream ifile('text.txt');
^
root@kali:~/Documents/cpp/week3# g++ 2.cpp
2.cpp:7:16: warning: character constant too long for its type
ifstream file('text.txt');
^~~~~~~~~~
2.cpp: In function ‘int main()’:
2.cpp:7:15: error: variable ‘std::ifstream file’ has initializer but incomplete type
ifstream file('text.txt');
^
root@kali:~/Documents/cpp/week3# g++ 2.cpp
2.cpp:7:15: warning: character constant too long for its type
istream file('text.txt');
^~~~~~~~~~
2.cpp: In function ‘int main()’:
2.cpp:7:25: error: invalid conversion from ‘int’ to ‘std::basic_istream<char>::__streambuf_type* {aka std::basic_streambuf<char>*}’ [-fpermissive]
istream file('text.txt');
^
In file included from /usr/include/c++/7/iostream:40:0,
from 2.cpp:1:
/usr/include/c++/7/istream:93:7: note: initializing argument 1 of ‘std::basic_istream<_CharT, _Traits>::basic_istream(std::basic_istream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>]’
basic_istream(__streambuf_type* __sb)
^~~~~~~~~~~~~
root@kali:~/Documents/cpp/week3# g++ 2.cpp
2.cpp:7:15: warning: character constant too long for its type
istream file('text.txt');
^~~~~~~~~~
2.cpp: In function ‘int main()’:
2.cpp:7:25: error: invalid conversion from ‘int’ to ‘std::basic_istream<char>::__streambuf_type* {aka std::basic_streambuf<char>*}’ [-fpermissive]
istream file('text.txt');
^
In file included from /usr/include/c++/7/iostream:40:0,
from 2.cpp:1:
/usr/include/c++/7/istream:93:7: note: initializing argument 1 of ‘std::basic_istream<_CharT, _Traits>::basic_istream(std::basic_istream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>]’
basic_istream(__streambuf_type* __sb)
^~~~~~~~~~~~~
root@kali:~/Documents/cpp/week3# g++ 2.cpp
root@kali:~/Documents/cpp/week3# ./a.out
qwerty
qwerty
root@kali:~/Documents/cpp/week3# ./a.out
qwerwertew1234424
qwerwertew1234424
root@kali:~/Documents/cpp/week3# g++ 2.cpp
root@kali:~/Documents/cpp/week3# ./a.out
12324324
12324324
qwewqrwtreyety
qwewqrwtreyetyroot@kali:~/Documents/cpp/week3# ./a.out
sdwdsd[A
sdwdsdroot@kali:~/Documents/cpp/week3# g++ 2.cpp
root@kali:~/Documents/cpp/week3# ./a.out
qwerty
qwerty
QQWERTYY
QQWERTYY
root@kali:~/Documents/cpp/week3# g++ 2.cpp
root@kali:~/Documents/cpp/week3# ./a.out
123123
123123
456456
456456@F�hU�sz�root@kali:~/Documents/cpp/week3# g++ 2.cpp
2.cpp: In function ‘int main()’:
2.cpp:12:20: error: invalid conversion from ‘char’ to ‘const char*’ [-fpermissive]
cout.write(ch,100);
^
In file included from /usr/include/c++/7/ostream:693:0,
from /usr/include/c++/7/iostream:39,
from 2.cpp:1:
/usr/include/c++/7/bits/ostream.tcc:182:5: note: initializing argument 1 of ‘std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::write(const _CharT*, std::streamsize) [with _CharT = char; _Traits = std::char_traits<char>; std::streamsize = long int]’
basic_ostream<_CharT, _Traits>::
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
root@kali:~/Documents/cpp/week3# g++ 2.cpp
0root@kali:~/Documents/cpp/week3# ./a.out
123
�Y��U�W��U�����1�Y��U��$7���������0��7�X��Uc9�F+�U�W��Y��U�W��U�����2�Y��U��$7���������0��7�X��Uc9�F+�U�W��Y��U�W��U�����3�Y��U��$7���������0��7�X��Uc9�F+�U�W��Y��U�W��U�����
�Y��U��$7���������0��7�X��Uc9�F+�U�W�123
123�U�W��U����root@kali:~/Documents/cpp/week3# g++ 2.cpp
root@kali:~/Documents/cpp/week3# ./a.out
awesfsa
awesfsa
asdfdsfsdaf
root@kali:~/Documents/cpp/week3#