我只想知道为什么我不能像这样用大括号创建对象()我不明白问题出在哪里
“bsnode.h”
#pragma once
#include <string>
#include <iostream>
template <class T>
class BSNode
{
public:
BSNode() {
}
void printNodes() const {
std::cout << "test" << std::endl;
}
};
“main.cpp”
#include "BSNode.h"
int main()
{
BSNode<int> bsnodeInt1();
BSNode<int> bsnodeInt2;
bsnodeInt1.printNodes();
bsnodeInt2.printNodes();
return 0;
}
我得到了这两个错误
Main.cpp 3表达式必须具有类类型
'.printnodes'左侧的main.cpp 3必须具有class/struct/union
BSNode<int> bsnodeInt1(); it's a function
BSNode<int> bsnodeInt2;. It's an object