可能重复:
为什么java中的文件名应该与类名相同?
我有一个名为的文件temp.java.我写了以下代码.为什么这样做?
class demo //not public keyword and not same as filename
{
public static void main(String []args)
{
System.out.println("this is Main method");
}
}
Run Code Online (Sandbox Code Playgroud)
为什么这不起作用?
public class demo
{
public static void main(String []args)
{
System.out.println("this is Main method");
}
}
Run Code Online (Sandbox Code Playgroud) 我想在cpp中创建接口,这样任何类实现该类,那么该类必须实现父类的函数.如果未实现所有功能,则必须显示错误.
class parent { // interface class
public :
virtual void display();
}
class base : public parent {
void display(); // this method must be implemented in this class
}
Run Code Online (Sandbox Code Playgroud)
请帮我在c ++中进行这种类型的继承.
这只是一个示例代码
class parent{ //abstact class
//pure virtual function
virtual fun=0;
}
class child : parent{
fun;
}
main()
{
//what should i do here,so i can add parent in vector
attach(child);
}
void attach(parent* p){
vector.push_back(p); //want to add reference of parent into vecotr
}
Run Code Online (Sandbox Code Playgroud)
我想把孩子投入父母但不能做任何人请帮助我吗?
我在Windows中使用c ++和winsock lib开发客户端服务器应用程序它工作正常,但如果它在网络上,一旦服务器监听启动,如果我删除网络电缆,那么服务器不会在任何线程中显示任何错误,所以服务器套接字知道网络拔掉电缆.如果有人知道请帮助我.
我希望vector在我的代码中作为返回类型的函数,比如
class SocketTransportClient{
void sendData(RMLInfoset *info){
vector<unsigned long>::iterator blockIterator;
vector<unsigned long> vectBlock=info->getRML(); // error : error C2440: 'initializing' : cannot convert from 'std::vector<_Ty>' to 'std::vector<_Ty>'
}
}
class RMLInfoset {
vector<unsigned int> RMLInfoset::getRML(){
return vectDataBlock;
}
}
Run Code Online (Sandbox Code Playgroud)
但它显示错误'无法从'std :: vector <_Ty>'转换为'std :: vector <_Ty>''所以请任何人帮助我,谢谢.