现在的位置: 首页 > 综合 > 正文

c++ java 区别(一)

2016年11月18日 ⁄ 综合 ⁄ 共 931字 ⁄ 字号 评论关闭

 

c++中的类

在main函数中定义时:

有构造函数的话

定义为:
如:
class student
{
public:
  student(int age)
  {
  }
  student(){}
};

void main()
{
  student a;//或
  student a(18);
}

java中的类
class student
{
  studnet ()
  {
  }
}

class Test
{
  public static void main()
  {
    student s=new student();
  }
}

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I begin to carefully write the blog, my first blog.

The follow is the English interpretation(My English is poor,I hope you can help me to find my grammer fault in the context):

C plus plus ,its class usage:

Define the class in main,which is like this:

You define a construct means first in your class:

for example:

class student
{
public:
  student(int age)
  {
  }
  student(){}
};

void main()
{
  student a;//或
  student a(18);
}

java ,its class usage:

class student
{
  studnet ()
  {
  }
}

class Test
{
  public static void main()
  {
    student s=new student();
  }
}

【上篇】
【下篇】

抱歉!评论已关闭.