调用函数传递的参数只能是临时变量,不能是成员变量

SunkingYang
C/C++领域优质创作者
博客专家认证
2015-03-18 02:39:32
void Ctest::getMeshinfoEx(Ogre::Entity* ent)
{
NasalFeeding *mNasal = new NasalFeeding;
size_t m_vertex_count1, m_index_count1;
Ogre::Vector3* m_vertices1;
Ogre::Vector2* m_texcoords1;
unsigned long* m_indices1;
mNasal->getMeshInfo(ent->getMesh(), m_vertex_count1, m_vertices1, m_texcoords1, m_index_count1, m_indices1);
int i = 0;
}

m_vertex_count1, m_vertices1, m_texcoords1, m_index_count1, m_indices1是几个输出参数,这样就可以得到几个变量的值,但如果将 m_vertex_count1, m_vertices1, m_texcoords1, m_index_count1, m_indices1变量声明为成员变量,则不能取倒值,百思不得其解。
同样的,用临时变量,在跟断点时,就能跟到值,如果将参数改为成员变量时,断点中的值不显示。
如图示:,如果把那几个变量改变为成员变量,则断点走到该语句时,鼠标移上去,变量没有值,没有任何反应
...全文
311 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
SunkingYang 2015-03-20
  • 打赏
  • 举报
回复
貌似是编译器引起的问题,重新清理工程后,可以了,不过断点不显示值得问题还是没解决
SunkingYang 2015-03-19
  • 打赏
  • 举报
回复
引用 3 楼 draculamx 的回复:
看样子没啥问题啊。。。你把这些变量设置成成员变量,在执行getMeshinfoEx方法之后,把这些成员变量的值输出,看有没有变化。
输出无效指针
draculamx 2015-03-18
  • 打赏
  • 举报
回复
看样子没啥问题啊。。。你把这些变量设置成成员变量,在执行getMeshinfoEx方法之后,把这些成员变量的值输出,看有没有变化。
SunkingYang 2015-03-18
  • 打赏
  • 举报
回复
引用 1 楼 draculamx 的回复:
size_t m_vertex_count1, m_index_count1;
Ogre::Vector3* m_vertices1;
Ogre::Vector2* m_texcoords1;
unsigned long* m_indices1;

这些变量,你定义成成员变量,具体是如何定义的?

mNasal->getMeshInfo

getMeshInfo这个函数的原型(或者声明),需要仔细看看

成员变量为共有,定义和局部一样
public:
// size_t m_vertex_count1, m_index_count1;
// Ogre::Vector3* m_vertices1;
// Ogre::Vector2* m_texcoords1;
// unsigned long* m_indices1;

getMeshInfo这个函数的原型:
void getMeshInfo(const Ogre::MeshPtr mesh,
size_t &vertex_count,
Ogre::Vector3* &vertices,
Ogre::Vector2* &texcoords,
size_t &index_count,
unsigned long* &indices,
const Ogre::Vector3 &position = Ogre::Vector3::ZERO,
const Ogre::Quaternion &orient = Ogre::Quaternion::IDENTITY,
const Ogre::Vector3 &scale = Ogre::Vector3::UNIT_SCALE);
draculamx 2015-03-18
  • 打赏
  • 举报
回复
size_t m_vertex_count1, m_index_count1; Ogre::Vector3* m_vertices1; Ogre::Vector2* m_texcoords1; unsigned long* m_indices1; 这些变量,你定义成成员变量,具体是如何定义的? mNasal->getMeshInfo getMeshInfo这个函数的原型(或者声明),需要仔细看看

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧