basics of inheritance - part 2invoking method of a base class in a derived class Typically, if your specialized implementations in derived class need to reuse the base class's generic implementation, you can…2024-06-14Coding
basics of inheritance - part 1C++ syntax of derivation 1234class base{ //...base class members} 1234class Derived: access-specifier Base{ //...derived class members} the base class is also called the super…2024-06-13Coding
union & struct & aggregate & constexprusing aggregate initialization on classes and structs aggregate initialization syntax 1Type objectName = {argument1,...,argumentN} alternatively 1Type objecname…2024-06-12Coding
union and structsizeof() a char* pointer's size is fixed at 4 bytes (on 32-bit system, and double it on 64-bit) and is independent of the volume of data being pointed to. declaring a friend of…2024-06-11Coding
constructor -3move constructor 123456789class MyString{ // pick implementation from Listing 9.9};MyString Copy(MyString& source) // function{ MyString copyForReturn(source.GetString())…2024-06-10Coding
constructor -2the difference of & used in reference and store address A reference & is a alias of variable and must be initialized before we use it, eg: 1234int a=6;//initialization…2024-06-09Coding
constructor and shadow copyingstrlen vs sizeof strlen method is used to find the length of an array whereas sizeof method is used to find the actual size of data, eg: 1234567891011strcpy(str,"this is a…2024-06-08Coding
functionreturn用来退出当前函数模块。 注意有返回值,即:return (num) 中(num)是某个返回值,则调用函数的时候可以赋值,比如如果返回是int类型可以这样赋值urnum=MyFunction(factor);,如果没有返回值则直接调用该函数的时候直接函数直接写在一行,即,执行该子函数的程序结果,但是没有返回值(不能赋值)…2024-06-07Coding
Arrays and Strings12warning: backslash and newline separated by space int colAndrowArray[3][3]= \ 此类换行错误,删除反斜杠\后面的空格,就不会有waring了。 两种换行方式 添加\或者 双引号"" 12345cout << "Hello \World"…2024-06-06Coding
Introduction -2使用变量和常量 std::cin不要用endl e.g. 下面写法是错误的 1cin >> typeNUmbe >>endl; 以上写法会报错!!! 在C++中,变量名可包含数字和字母,但不能以数字打头。变量名不能包含空格和算术运算符(+、-等)。另外,变量名不能是系统函数的关键字。例如,将变量命名为return…2024-06-05Coding