小编Ste*_*eld的帖子

Visual Studio 中的“Step Over”和“Step Into”

我注意到在 VS 中使用 F10 - Step Over 会自动跳过我的功能。这是为什么?我确实注意到 F11- Step Into 确实进入了我的函数,但是它从各种 C 库中输入了我正在使用的函数的实现代码,这真的很烦人。

有什么方法可以在不输入包含库的实现代码的情况下在我的函数中逐步运行?

c visual-studio

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

没有合适的用户定义转换

我正在尝试编写一个包装数值的C++程序,我这样做是通过编写一个处理两个简单函数的超类和一个运算符重载函数来完成的.这是我的代码:

#include <iostream>
#include <string>
#include <sstream>
using namespace std;


template <class T>
class Number {
protected:
    T number;

public:
    Number(T num) {
        number = num;
    }

    string mytype() {
        return typeid(number).name();
    }

    string what_am_i() {
        ostringstream oss;
        oss << "I am " << Number<T>::mytype() << " and my nanana is " << number;
        return oss.str();
    }

    Number operator+ (Number an) {
        Number brandNew = NULL;
        brandNew.number = number + an.number;
        return brandNew;
    }
};

class MyInt : public Number<int> …
Run Code Online (Sandbox Code Playgroud)

c++ operator-overloading

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

fork()函数永远不会返回0

我目前正在尝试在C中运行fork函数,在代码的子部分,我试图使用exacvp执行命令,但在执行之前我正在尝试一个永远不会执行的printf函数.我在调试中运行了这个,我注意到pid从未被分配0.我在一个单独的项目上尝试了一个简单的fork示例,它运行顺利.有没有人知道为什么孩子部分永远不会执行?

int startProcesses(int background) {
int i = 0;

while(*(lineArray+i) != NULL) {
    int pid;
    int status;
    char *processName;

    pid = fork();

    if (pid == 0) {

        printf("I am child");
        // Child Process
        processName = strtok(lineArray[i], " ");
        execvp(processName, lineArray[i]);
        i++;
        continue;

    } else if (!background) {

        // Parent Process
        waitpid(pid, &status, 0);
        i++;
        if(WEXITSTATUS(status)) {
            printf(CANNOT_RUN_ERROR);
            return 1;
        }
    } else {
        i++;
        continue;
    }
}
return 0;
Run Code Online (Sandbox Code Playgroud)

}

c linux

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

在构造函数中使用:base()

我目前正在尝试构造一个派生自不同对象的对象,但在调用基础构造函数之前,我想进行一些参数验证.

public FuelMotorCycle(string owner) : base(owner)
{
    argumentValidation(owner);
}
Run Code Online (Sandbox Code Playgroud)

现在我明白了最初首先调用基础构造函数,有没有办法只能在argumentValidation方法之后调用它?

c# inheritance

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

==运算符导致结构上的编译时错误

我在MSDN网站上看到,如果值类型操作数相等,则==运算符将返回true .

要完全理解我已经声明了以下结构(据我所知,它被认为是C#中的值类型),并使用了==运算符,但由于某些原因我不明白,我得到以下编译错误.

有没有人知道为什么编译器会显示这些错误,即使p1和p2明显相等?

struct Point {
  int m_X;
  int m_Y;  
}

Point p1 = new Point(10, 15);
Point p2 = new Point(10, 15);
Point p3 = p2;
bool equals = (p1 == p2); // Compile Error 
bool equals = (p2 == p3); // Compile Error 
bool equals = p1.Equals(p3); 
bool equals = p1.Equals(p2); 
Run Code Online (Sandbox Code Playgroud)

谢谢!

c#

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

标签 统计

c ×2

c# ×2

c++ ×1

inheritance ×1

linux ×1

operator-overloading ×1

visual-studio ×1