Change
QGLContext mContext = QGLContext( mFormat );
To copy to clipboard, switch view to plain text mode
to
QGLContext mContext( mFormat );
To copy to clipboard, switch view to plain text mode
I think compiler "thinks" you want to use copy-constructor, which is private. But in fact the copy-constructor will not be used in this case. Look here:
#include <iostream>
class T
{
public:
T(){
std::cout << "T()\n";
}
T(const T&){
std::cout << "T(const T&)\n";
}
T(int){
std::cout << "T(int)\n";
}
T& operator=(const T& t){
std::cout << "T& operator\n";
}
};
int main(){
T t = T(10);
return 10;
}
#include <iostream>
class T
{
public:
T(){
std::cout << "T()\n";
}
T(const T&){
std::cout << "T(const T&)\n";
}
T(int){
std::cout << "T(int)\n";
}
T& operator=(const T& t){
std::cout << "T& operator\n";
}
};
int main(){
T t = T(10);
return 10;
}
To copy to clipboard, switch view to plain text mode
This should print T(int), which means the copy-constructor is not used. But this:
#include <iostream>
class T
{
public:
T(){
std::cout << "T()\n";
}
T(int){
std::cout << "T(int)\n";
}
T& operator=(const T& t){
std::cout << "T& operator\n";
}
private:
T(const T&){
std::cout << "T(const T&)\n";
}
};
int main(){
T t = T(10);
return 10;
}
#include <iostream>
class T
{
public:
T(){
std::cout << "T()\n";
}
T(int){
std::cout << "T(int)\n";
}
T& operator=(const T& t){
std::cout << "T& operator\n";
}
private:
T(const T&){
std::cout << "T(const T&)\n";
}
};
int main(){
T t = T(10);
return 10;
}
To copy to clipboard, switch view to plain text mode
does not compile:
test.cpp: In function 'int main()':
test.cpp:54:3: error: 'T::T(const T&)' is private
test.cpp:60:12: error: within this context
(tested with g++ 4.5.2)
Bookmarks