我们的代码中有以下类结构
Class A: public CDialog, public Base1, public Base2
{
};
Run Code Online (Sandbox Code Playgroud)
在实施A类时,我们有以下内容:
BEGIN_MESSAGE_MAP( A, CDialog )
ON_WM_SIZE()
END_MESSAGE_MAP()
Run Code Online (Sandbox Code Playgroud)
请注意,Base1和Base2不从CDialog或任何其他MFC类继承.
在VC6上,编译成功.但是在VC9上我们得到以下错误代码:
错误C4407:在成员表示的不同指针之间强制转换,编译器可能生成错误的代码.
此错误代码指向ON_WM_SIZE的位置.
有谁可能告诉我一个解决方案.提前致谢.
玩家
在Visual C++(2008和2010)中,以下代码无法编译,并出现以下错误:
#include <memory>
void Foo( std::shared_ptr< int > test = ::std::make_shared< int >( 5 ) )
{
}
class P
{
void
Foo( std::shared_ptr< int > test = ::std::make_shared< int >( 5 ) )
{
}
};
Run Code Online (Sandbox Code Playgroud)
错误C2039:'make_shared':不是'`global namespace''的成员
错误C3861:'make_shared':找不到标识符
它抱怨P :: Foo()的定义不是:: Foo().
有人知道为什么Foo()有一个与std :: make_shared但不是P :: Foo()的默认参数有效吗?
我正在尝试使用C++和Visual C++ 2008 Express Edition上的MySQL ODBC 5.1驱动程序连接到MySQL服务器.
我正在遵循MSDN的这些说明:
唯一的区别是我必须将所有转换SQLCHAR为SQLWCHAR,以匹配函数参数,希望这不会影响连接字符串.
每次我连接时都得到SQL_ERROR返回值.所以我假设连接字符串或连接语句有问题.
我试过了
DNS=TestConnection; UID=user; PSW=password
和
SERVER=localhost; DRIVER={MySQL ODBC 5.1 Driver}; PORT=3306; UID=user; PSW=password; DATABASE=dbo;
和其他类似的连接字符串.
被调用的DNS TestConnection与后一个连接字符串具有相同的信息.
架构是dbo,并且有一个表testfire使用以下列规范调用:
TEST_ID( INT(11), PRIMARY, AUTO INCREMENT)
TEST_STRING( VARCHAR(50) )
TEST_INTEGER( INT(11) )
TEST_FLOAT( FLOAT )
TEST_DATE( DATETIME )
Run Code Online (Sandbox Code Playgroud)
有3行:
ID STRING INT FLOAT DATE
------------------------------------------------------
| 1 | Test 1 | 1 | 0.1 | 2001-01-01 00:00:00 |
| …Run Code Online (Sandbox Code Playgroud) 我想创建一个函数,它可以使用不同类型的迭代器来存储相同类型的对象:
第一个是std::map包含shared_ptr<Foo>(typedef-ed as FooMap),另一个是std::list包含shared_ptr<Foo>(FooList)的.
我非常喜欢MSalters为类似问题提出的解决方案并试图实现boost::variant迭代器,该函数将作为参数从第一个迭代到第二个迭代.
我的函数看起来像这样(简化了很多):
set<Foo> CMyClass::GetUniqueFoos(FooIterator itBegin, FooIterator itEnd)
{
set<Foo> uniques;
for(/**/;
apply_visitor(do_compare(), itBegin, itEnd); // equals "itBegin != itEnd"
apply_visitor(do_increment(), itBegin)) // equals "++itBegin"
{
// Exact mechanism for determining if unique is omitted for clarity
uniques.insert( do_dereference< shared_ptr<Foo> >(), itBegin) );
}
return uniques;
}
Run Code Online (Sandbox Code Playgroud)
FooIterator和访问者定义如下:
typedef
boost::variant<
FooMap::const_iterator,
FooList::const_iterator>
FooIterator;
struct do_compare : boost::static_visitor<bool>
{
bool operator() (
const …Run Code Online (Sandbox Code Playgroud) 使用VC9(2008)和VC10(2010)使用后续步骤编译我自己的php扩展后:
http://blog.slickedit.com/2007/09/creating-a-php-5-extension-with-visual-c-2005/
初始化php时我得到下一个错误:
PHP Warning: PHP Startup: FirstPHPExt Module: Unable to initialize module
Module compiled with build ID=API20090626,TS
PHP compiled with build ID=API20090626,TS,VC9
These options need to match
in Unknown on line 0
Run Code Online (Sandbox Code Playgroud)
为什么不说我用VC9编译模块?
更多信息:
操作系统:Windows7 x64 PHP:5.3.3,TS,VC9
我有重载运算符的代码new.下面的代码在Linux(gcc4x)下运行正常,但不适用于Windows(Visual C++ 2008 Express Edition)
Visual Studio 2008 Express Edition下的代码报告
错误C2660:operator new []:函数不带1个参数
class dummy{};
void* operator new[] (size_t size, dummy gcp)
{
return ::operator new[](size); //error
}
int main()
{
dummy dummyobj;
dummy* ptr = new (dummyobj) dummy[5];
return 0;
}
Run Code Online (Sandbox Code Playgroud) 嗨我使用c ++,我可以找到一个简单的方法从一组数字中获取一个数组,其中包含ex:{1,2,3}之间的所有可能组合
{ {3,1,2},
{1,2,3},
{3,2,1},
{1,3,2},
{2,1,3},
{2,3,1}
};
Run Code Online (Sandbox Code Playgroud)
问题是如果我得到5个或更多数字如何使120组合
我想为我的应用程序创建一个对话框,显示一条消息并显示标准的红色圆圈,中间是白色的"x"; 在我看来,这是一个非常标准的Windows对话框.我对MFC有些新意,所以除了创建对话框资源,从microsoft的最佳实践页面复制红色x的图像,包括作为对话框项目,我不知道是否还有一个快捷方式.然后编码我自己的.当然有更标准的方法来做到这一点?
我在这里使用Visual C++ 2008(9.x),当我遇到生成DIV而不是IDIV的编译器时,我正准备一个固定点值.我将代码折叠成一小块以完全重现:
short a = -255;
short divisor16 = 640; // unsigned, 16-bit
unsigned int divisor32 = 640; // unsigned, 32-bit
unsigned short s_divisor16 = 640; // signed, 16-bit
int s_divisor32 = 640; // signed, 32-bit
int16_t test1 = (a<<8)/divisor16; // == -102, generates IDIV -> OK
int16_t test2 = (a<<8)/s_divisor16; // == -102, generates IDIV -> OK
int16_t test3 = (a<<8)/divisor32; // == bogus, generates DIV -> FAIL!
int16_t test4 = (a<<8)/s_divisor32; // == -102, generates IDIV -> …Run Code Online (Sandbox Code Playgroud) 我正在使用Visual Studio 2008,并有两个类Parent和Child.Parent在头文件中声明了一些静态const变量,然后在cpp文件中定义.当我尝试在子类的switch语句中使用define作为案例时,我得到错误:C2051:case表达式不是常量.所以我做了一些测试,我看到的行为有些不一致.
// Parent.h
class Parent
{
public:
Parent();
~Parent(void) { }
static const unsigned long A = 1;
static const unsigned long B;
};
// Parent.cpp
#include "Parent.h"
const unsigned long Parent::B = 2;
Parent::Parent()
{
// Everything works fine here
unsigned long l;
switch(l)
{
case A:
break;
case B:
break;
default:
break;
}
}
// Child.h
#pragma once
#include "Parent.h"
class Child :
public Parent
{
public:
Child(void);
virtual ~Child(void) { } …Run Code Online (Sandbox Code Playgroud) visual-c++-2008 ×10
c++ ×7
visual-c++ ×3
mfc ×2
assembly ×1
driver ×1
inheritance ×1
iterator ×1
mysql ×1
new-operator ×1
odbc ×1
pecl ×1
permutation ×1
php ×1
templates ×1
windows ×1