小编bad*_*053的帖子

错误:请求成员...这是非类型的

我意识到错误来自于在自定义类中使用向量,但我一直在努力解决它们.如何在类对象的一部分调用向量方法?

这些是我得到的错误:

Word.cpp: In member function ‘void Word::addPosition(int)’:
Word.cpp:20: error: request for member ‘push_back’ in ‘((Word*)this)->Word::positions’, which is of non-class type ‘std::vector<int, std::allocator<int> >*’
Word.cpp: In member function ‘int Word::getPosition(int)’:
Word.cpp:26: error: request for member ‘size’ in ‘((Word*)this)->Word::positions’, which is of non-class type ‘std::vector<int, std::allocator<int> >*’
Word.cpp:27: error: request for member ‘size’ in ‘((Word*)this)->Word::positions’, which is of non-class type ‘std::vector<int, std::allocator<int> >*’
Word.cpp:29: error: cannot convert ‘std::vector<int, std::allocator<int> >’ to ‘int’ in return
Run Code Online (Sandbox Code Playgroud)

#pragma once
#include <string>
#include <vector> …
Run Code Online (Sandbox Code Playgroud)

c++

5
推荐指数
2
解决办法
4万
查看次数

添加多个UILabel,每个标签都有可变线

我有一个视图,我想要它和一组标签,但标签的数量和每个标签的文本长度各不相同.

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, 300, 50)];
label.text = @"Varying text length here";
label.numberOfLines = 0;
[label sizeToFit];
[[self view] addSubview:label];
Run Code Online (Sandbox Code Playgroud)

当标签位于1-4行之间时,以25的设定距离以编程方式在此标签下添加另一个标签的最简单方法是什么?

iphone xcode objective-c ios

2
推荐指数
1
解决办法
2210
查看次数

标签 统计

c++ ×1

ios ×1

iphone ×1

objective-c ×1

xcode ×1