只是想知道,c ++中的哪种编程错误会导致防病毒软件认为编译的exe文件是病毒?这似乎发生在我玩指针的时候。我是否真的创造了对我的计算机有害的东西,或者只是防病毒给出了误报和安全忽视?
主
#include "node.h"
#include <conio.h>
int main(){
Node a(5);
Node b(3);
Node c(2);
addSuccessor(&a,&b);
addSuccessor(&a,&c);
_getch();
return 0;
}
node.h
#include <ostream>
#include <string>
#include <sstream>
#include <iostream>
#include <vector>
using namespace std;
class Node{
public:
Node();
Node(short s);
~Node();
void setValue(short s);
short getValue();
vector<Node*> getSuccessors();
friend ostream & operator <<(ostream &os, Node &n);
private:
short value;
vector<Node*> successors;
};
void addSuccessor(Node* initial, Node* successor)
node.cpp
#include "node.h"
#include <string>
Node:: Node(){
value = 0;
}
Node::~Node(){
}
Node:: Node(short s){
value = s;
}
void Node::setValue(short n){
value = n;
}
short Node::getValue(){
return value;
}
vector<Node*> Node::getSuccessors(){
return successors;
}
void addSuccessor(Node* initial, Node* successor){
initial->getSuccessors().push_back(successor);
}
ostream & operator <<(ostream &os, Node &n){
os << "N:"<< n.getValue() << "\n";
return os;
}