小编42c*_*kes的帖子

对Windows命令行命令强制退出代码为零

如何在不改变其行为方式的情况下强制退出代码为零cmd命令

linux相当于什么意思

netstat -an | grep 12035 || true
Run Code Online (Sandbox Code Playgroud)

我试过的东西是

C:\>netstat -ano | find "25000" | exit 0
Run Code Online (Sandbox Code Playgroud)

虽然它强制退出代码0,但在成功时它不会显示所需的输出

例如:

C:\>netstat -ano | find "25000"
TCP    0.0.0.0:25000          0.0.0.0:0              LISTENING       4832

C:\>netstat -ano | find "25000" | exit 0
Run Code Online (Sandbox Code Playgroud)

知道是否有办法?

windows cmd exit-code

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

从嵌套类的函数访问父类的非静态成员

我试图在论坛中窥探一个类似的问题,这可能会帮助我取得成功.

我的C++程序中有一个嵌套类.我试图从嵌套类中的函数访问父类的变量,但我遇到以下错误

ERROR: A non static member reference must be relative to a specific object
Run Code Online (Sandbox Code Playgroud)

我试图访问的变量受到保护,嵌套类是公共的(它的功能也是如此)

以下是描述(或努力)该场景的代码片段

头文件

class A
{
    protected:
        D x;

    public:

        int func1(int a);

        class B : protected C
        {
            int func2(int a);   
        }
}   
Run Code Online (Sandbox Code Playgroud)

CPP文件

int A::func1(int a)
{
    x = 5;
    B z;
    int b = z.func2(a);
}

int A::B::func2(int a)
{
    int c = x.getValue(a);      /* ERROR: A non static member reference 
                                   must be relative to a specific object */
}
Run Code Online (Sandbox Code Playgroud)

从某个地方

A …
Run Code Online (Sandbox Code Playgroud)

c++ access-modifiers nested-class

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

读/写void *变量的单个字节

如果我有

void *temp = malloc(128);
memset(temp, 0 , 128);  
Run Code Online (Sandbox Code Playgroud)

我想单独读取第一个字节,这是我在做什么。

char a[2];
strncpy(a, (char*)temp, 1);
int p = a[0];
//p will be zero in this case
Run Code Online (Sandbox Code Playgroud)

Q1。我敢肯定,有一种更优雅的方法可以达到相同目的。如果是这样,那会是什么?

Q2。有没有办法我可以单独更改单个字节的值?

假设我希望第一个字节的值等于int值48(即00110000),我该怎么做?我写的没有任何进展。

c c++ malloc memset void-pointers

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