类的定义后main函数如何写?

学生一枚,最近学习了函数类的定义,但主函数怎么写才能用上定义的类函数的?调用还是指针?

直接调用函数名即可,但是要传对应 的参数

类的定义要用到class的吧

你们竟然能看明白,给个意见,下次最好把例子写一个,别人能够理解!!

我是想问你是通过什么途径学习的,竟然没教你怎么使用类和如何调用类的方法。。

 #include <iostream>

using namespace std;

class Student
{
public:
    Student(const char* name, const char* no)
        :name(name), no(no)
    {
    }

    void whoAreYou()
    {
        cout<<"I am "<<name<<", my no: "<<no<<endl;
    }

private:
    string name;
    string no;
};

int main(void)
{
    Student xiaoming("xiaoming", "2017142312");
    xiaoming.whoAreYou();
}