小编viv*_*321的帖子

共享内存编程错误(O_RDRW、PROT_WRITE、MAP_SHARED)

我正在尝试为共享内存对象运行程序。我的代码如下:

#include <stdio.h>  /*adding standard input output library*/
#include <stdlib.h> /*standard library for four variable types, several macros, and various functions for performing general functions*/
#include <string.h> /*adding string library*/
#include <sys/fcntl.h>  /* library for file control options */
#include <sys/shm.h> /*library for shared memory facility*/
#include <sys/stat.h> /*data returned by the stat() function*/
int main()
{
    /* the size (in bytes) of shared memory object */
    const int SIZE=4096;
    /* name of the shared memory object */
    const char …
Run Code Online (Sandbox Code Playgroud)

c linux bash operating-system shared-memory

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

为什么这个程序没有编译

#include <iostream>
class Abc // created class with name Abc
{
    void display()//member function
    {
        cout<<"Displaying NO."<<endl;
    }
};
int main()
{
    Abc obj;//creating object of the class
    obj.display();//calling member function inside class
}
Run Code Online (Sandbox Code Playgroud)

它返回错误为

main.cpp: In function 'int main()':
main.cpp:5:10: error: 'void Abc::display()' is private
     void display()
          ^
main.cpp:13:17: error: within this context
     obj.display();
                 ^
Run Code Online (Sandbox Code Playgroud)

我试图使显示功能,public int main但它给出了错误

main.cpp:5:11: error: expected ':' before 'void'
    public void display()
           ^
Run Code Online (Sandbox Code Playgroud)

c++

-8
推荐指数
1
解决办法
94
查看次数

标签 统计

bash ×1

c ×1

c++ ×1

linux ×1

operating-system ×1

shared-memory ×1