小编cha*_*tte的帖子

错误:基类构造函数必须显式初始化父类构造函数

我是c ++的新手.当我尝试编译下面的代码时,我收到此错误

constructor for 'child' must explicitly initialize the base class 'parent' which does not have a default constructor child::child(int a) {

这是我的课

#include<iostream>
using namespace std;

class Parent
{   
public :
    int x;
    Parent(int a);
    int getX();
};
Parent::Parent(int a)
{
    x = a;
}
int Parent::getX() 
{
    return x;
}
class Child : public Parent
{
public:
    Child(int a);   
};
Child::Child(int a) 
{
    x = a;
}
int main(int n , char *argv[]) 
{

}
Run Code Online (Sandbox Code Playgroud)

为什么我收到此错误?我该如何解决?提前致谢

c++ constructor initialization derived-class

27
推荐指数
4
解决办法
3万
查看次数

在Android中使用largeheap是一个很好的做法吗?

我正在开发中NDK.它挂起来了Galaxy S3.为了测试,我投入android:largeheap = "true"Manifest.然后没有悬而未决的问题.这是一个好用的做法largeHeap="true"吗?

由于此标记,Google是否有机会拒绝我的版本?如何在不使用的情况下阻止我的应用挂起largeheap="true"

android android-ndk

8
推荐指数
2
解决办法
5057
查看次数

LOCAL_EXPORT_C_INCLUDES和LOCAL_C_INCLUDES之间的区别

有人请解释LOCAL_EXPORT_C_INCLUDESLOCAL_C_INCLUDESandroid 之间有什么区别mk file.

android android-ndk

7
推荐指数
1
解决办法
5685
查看次数

在c ++中暂停程序执行5秒

我想暂停执行c ++程序5秒钟.在Android Handler.postDelayed具有我想要的功能.有没有类似于c ++的东西?

c++

5
推荐指数
2
解决办法
2万
查看次数

模板中c ++继承的模板类

我有一个模板类.

   template <class A> class TemplateClass
  {
      //functions
  }
Run Code Online (Sandbox Code Playgroud)

我有以下课程

 class B : A
 {
      //functions
 }

 class C : A 
{
   //functions
}
Run Code Online (Sandbox Code Playgroud)

我怀疑为什么不可能定义如下:

TemplateClass<A> *instance;
instance = new TemplateClass<B>; // A is the super class of B
Run Code Online (Sandbox Code Playgroud)

提前致谢

c++

2
推荐指数
1
解决办法
63
查看次数

在代码块中找不到fontconfig / fontconfig.h

我正在尝试在Ubuntu 14的Codeblocks IDE中构建Cocos2d-x项目fontconfig/fontconfig.h。编译时未发现错误。我被困在这里。我该如何解决?

codeblocks cocos2d-x

1
推荐指数
1
解决办法
2307
查看次数