關鍵字是用來決定哪些成員要使用子類別中的定義
// A a = new B(); //virtuall - new example
//
// A -------------> print (Call A)
// |
// -------------> B print (Call B)
//
namespace virtual_new
{
public class A
{
public virtual void print() { Console.WriteLine("Call A"); } // virtual here is not necessary!
}
public class B : A
{
public new void print() { Console.WriteLine("Call B"); }
}
public class Program
{
public static void Main(string[] args)
{
A a = new B();
a.print(); // Output: Call A
}
}
}
bloggerads
2014年12月30日 星期二
2014年12月10日 星期三
C++ Compiler : g++ 指令介紹
以下提供一些g++指令參數解釋,基本上就是用來生成執行檔/dll檔/obj檔
# Generate file.o
g++ -c file.cpp
# Generate Assembly : file.s
g++ -S file.cpp
# Convert file.o to file_dll.dll (需要先把cpp檔做成obj檔再來轉成dll檔)
g++ -shared file.o -o file_dll.dll
# Generate file.exe
g++ file.cpp -o file
# Generate file.exe from object and cpp files
g++ file.cpp obj.o -o file
# Generate main.exe from dll and cpp files
g++ file_dll.dll main.cpp -o main
# Alternative solution to generate main.exe from file_dll.dll and main.cpp , -L. means current dir
g++ -L. -lfile_dll main.cpp -o main
# Show all the warning
gcc -Wall -o main main.c
# Warning as error
gcc -Wall -Werror -o main main.c
# Generate file.o
g++ -c file.cpp
# Generate Assembly : file.s
g++ -S file.cpp
# Convert file.o to file_dll.dll (需要先把cpp檔做成obj檔再來轉成dll檔)
g++ -shared file.o -o file_dll.dll
# Generate file.exe
g++ file.cpp -o file
# Generate file.exe from object and cpp files
g++ file.cpp obj.o -o file
# Generate main.exe from dll and cpp files
g++ file_dll.dll main.cpp -o main
# Alternative solution to generate main.exe from file_dll.dll and main.cpp , -L. means current dir
g++ -L. -lfile_dll main.cpp -o main
# Show all the warning
gcc -Wall -o main main.c
# Warning as error
gcc -Wall -Werror -o main main.c
訂閱:
文章 (Atom)