我知道一个是面向过程,一个是面向对象。
但是如果一个问题是分别用c和c++输出hello world
c: #include<stdio.h> int main(){printf("hello world\n");return 0;}
c++:#include<iostream.h> void main() {cout<<"hello world"<<endl;}
语法上很难看到区别对吧?如果是c#:
public void button_onclick(object sender,eventargs e){reponse.write("hello world<br />");}
这很明显语法不一样。
从面向对象上,c++的面向对象体现在哪里?main函数进入,调用其他函数。c语言也是如此。
纠结,明白人帮我举例解释下吧,谢谢。
我觉得你回答的很好。我没用过c++封装。
能举个封装实现的例子吗?
我这样封装对吗?
public class class1{
public void print(string str){
print(%s,str);}}
void main()
{
class1.print("hello world");
}