小编Red*_*edX的帖子

防止数组从*[N]衰减到**

我已经声明了我的数组:

FT_Interface<4096> *to_make_ft[3] = { /* initialization with existing objects */ };
Run Code Online (Sandbox Code Playgroud)

我的界面声明如下:

template<cyg_ucount32 S, int N>
class FT_Thread {
  FT_Thread(FT_Interface<S> *entry[N]){}
};
Run Code Online (Sandbox Code Playgroud)

我称之为(正如预期的那样):

FT_Thread<4096, 3> ft(to_make_ft);
Run Code Online (Sandbox Code Playgroud)

但它抱怨说指针已经腐烂了.

ecos/install/include/ft/thread.hxx:70: error: incompatible types in assignment of ‘FT_Interface<4096u>**’ to ‘FT_Interface<4096u>* [3]’

有没有办法防止这种情况发生?

c++

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

变量名中的__COUNTER__

我见过这个问题:

如何使用宏在C++中生成随机变量名?

通过以下答案:https://stackoverflow.com/a/1675203/551045

我试图在clang中实现它.

这里是我的报关表:

#define TRACE(stream) FuncTrace x#__COUNTER__ (llvm::errs(), "hallo", 1)
Run Code Online (Sandbox Code Playgroud)

我尝试了所有的变化x##__COUNTER__; x ## __COUNTER__等等,但似乎没有工作.

这可能是一个铿锵的bug吗?clang 帮助页面说它有__COUNTER__宏.

最后宏我需要这样的东西:

#define TRACE(stream) FuncTrace x#__COUNTER__ (stream, __FUNCTION__, __LINE__)
Run Code Online (Sandbox Code Playgroud)

c++ macros clang c-preprocessor

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

.gitignore不会忽略`git status`中带有空格的文件名

我做的时候git status得到:

#       modified:   COM/config/Config/Edit Project Settings.lnk
Run Code Online (Sandbox Code Playgroud)

但在我的.gitignore中,我有:

*.lnk
Run Code Online (Sandbox Code Playgroud)

这里发生了什么?这可能是空白的问题吗?

git gitignore

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

该程序没有提供所需的输出.错误的FIFO实现?

这是一个使用的FIFO程序linked list.该程序没有提供所需的输出,但会生成一个长循环,该循环在某个时间后停止并且有一条消息表明程序已停止工作.问题是什么 ?

#include <iostream>
using namespace std;

struct node {
      int data;
      struct node* previous; // This pointer keeps track of the address of the previous node
};

struct queue {
      node* first;
      node* last;
};

node* dataNode_P_A; 

bool loop = true;

struct node* enterData();
struct node* enter_N_Data();
void displayQueue();

int main() {
    struct node* dataNode= enterData();

    while( loop ) {
        cout << "Want to enqueue ? Press y/n : ";
        char ans;
        cin >> ans;
        if( …
Run Code Online (Sandbox Code Playgroud)

c++ queue fifo visual-c++ data-structures

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

如何将我的程序转换为使用新的c ++标准?<iostream.h>等

如何将我的程序转换为使用新的c ++标准?我有问题<iostream.h>

main.cpp:3:22: fatal error: iostream.h: No such file or directory 
#include <iostream.h>
          ^
compilation terminated.
Run Code Online (Sandbox Code Playgroud)

这是在线编译器:

http://www.compileonline.com/compile_cpp11_online.php

#include <iostream.h>
#include <fstream.h>
#include <string.h>
#include <iomanip.h>
#include <conio.h>

class phoneBook{
    char name[20],phno[15];
    public:
    void getdata();
    void showdata();
    char *getname(){ return name; }
    char *getphno(){ return phno; }
    void update(char *nm,char *telno){
        strcpy(name,nm);
        strcpy(phno,telno);
    }
};

void phoneBook :: getdata(){
    cout<<"\nEnter Name : ";
    cin>>name;
    cout<<"Enter Phone No. : ";
    cin>>phno;
}

void phoneBook :: showdata(){
    cout<<"\n";
    cout<<setw(20)<<name;
    cout<<setw(15)<<phno; …
Run Code Online (Sandbox Code Playgroud)

c++

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

请帮助这个C++代码(可修改的左值)

这段代码有问题,

#include <iostream>
#include <conio.h>
using namespace std;

class Circle {
        double x, y, r;
public:
        Circle (double a=1.0, double b=1.0, double c=1.0) { x=a; y=b; r=c; }
        ~Circle() {}
        double Area();
        double getRadius();


};

class Conus {
                double height;
                Circle C;
        public:
                Conus (double , double , double , double );
                ~Conus() {};
                double Volume();
                void setRadius(double );
        };

Conus::Conus(double h, double a, double b, double c)
        : C (a, b, c)
{
        height=h;
}
double Circle::Area() { return …
Run Code Online (Sandbox Code Playgroud)

c++

-6
推荐指数
1
解决办法
133
查看次数