小编use*_*533的帖子

“pos ->* op 中的操作符 ->* 不匹配”

编译以下代码时出现以下错误。我很困惑,无法弄清楚这里出了什么问题。成员函数指针解除引用是否错误?

\n\n

错误:

\n\n
#g++ fp.cpp\nfp.cpp: In member function \xc3\xa2void Y::callfptr(void (X::*)(int))\xc3\xa2:\nfp.cpp:33: error: no match for \xc3\xa2operator->*\xc3\xa2 in \xc3\xa2pos ->* op\xc3\xa2\n
Run Code Online (Sandbox Code Playgroud)\n\n

程序文件

\n\n
#include <iostream>\n#include <vector>\nusing namespace std;\n\nclass B {\n // some base class\n};\n\nclass X : public B {\n public:\n  int z;\n  void a(int a) {\n    cout << "The value of a is "<< a << endl;\n  }\n  void f(int b) {\n    cout << "The value of b is "<< b << endl;\n  }\n};\n\nclass Y : public B {\n …
Run Code Online (Sandbox Code Playgroud)

c++ pointers function

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

错误:<token之前的预期模板名称

您好我收到以下错误

templateatt.cpp:4:32: error: expected template-name before ‘<‘ token
templateatt.cpp:4:32: error: expected â{â before ‘<‘ token
templateatt.cpp:4:32: error: expected unqualified-id before ‘<‘ token
Run Code Online (Sandbox Code Playgroud)

当我编译以下cpp文件时:

    #include<iostream>

    template <class R, class T>
    class mem_fun_t: unary_function<T*, R> {
      R (T::*pmf)();
    public:
      explicit mem_fun_t(R (T::*p)()):pmf(p){}
      R operator() (T *p) const { return (p->*pmf()); }
    };

    int main() {
      return 0;
    }
Run Code Online (Sandbox Code Playgroud)

任何帮助都会很棒.我被困在这里.

c++ templates

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

sem_wait的Coredump

我在这里有一个相当奇怪的问题,或者我不知道它的工作方式,但是无论如何,我下面的程序都会以适当的方式正确创建信号量并首次运行到结尾。但是,如果信号灯已存在,则SEGFaults在sem_wait上。我在64位Fedora 17上运行此程序。这是否与错误有关?

#include <stdio.h>          /* printf()                 */
#include <stdlib.h>         /* exit(), malloc(), free() */
#include <sys/types.h>      /* key_t, sem_t, pid_t      */
#include <sys/shm.h>        /* shmat(), IPC_RMID        */
#include <errno.h>          /* errno, ECHILD            */
#include <semaphore.h>      /* sem_open(), sem_destroy(), sem_wait().. */
#include <fcntl.h>          /* O_CREAT, O_EXEC          */

int
main() {


        sem_t *mysem;
        int oflag = O_CREAT | O_EXCL;
        mode_t mode = 0777;
        const char semname[] = "mysem";
        unsigned int value = 1;
        int sts;


        mysem = sem_open(semname, oflag, mode, value);
        //sem_unlink(semname); …
Run Code Online (Sandbox Code Playgroud)

c linux synchronization ipc fedora

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

标签 统计

c++ ×2

c ×1

fedora ×1

function ×1

ipc ×1

linux ×1

pointers ×1

synchronization ×1

templates ×1