调用vector时我得到这个编译器错误size().为什么?
#include <vector>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cassert>
using namespace std;
class Vertex {
float firstValue;
float secondValue;
float thirdValue;
Vertex (float first, float second, float third){
firstValue=first;
secondValue=second;
thirdValue=third;
}
};
int main()
{
cout<<"This program loads a 3D .off object. \nEnter the name of the file that describes it "<<endl;
string inputFileName;
getline(cin, inputFileName);
ifstream inputFileStream;
inputFileStream.open(inputFileName.data());
assert (inputFileStream.is_open());
string actualLine;
for(;;){
inputFileStream>>actualLine;
istringstream actualLineStream(actualLine);
std::vector<float> results( std::istream_iterator<int>(actualLineStream)
, std::istream_iterator<int>() ); …Run Code Online (Sandbox Code Playgroud) 我有一个完整的ArrayList:
class TransitionState {
Position positionA;
Position positionB;
int counter;
public boolean equals (Object o){
if (o instanceof TransitionState){
TransitionState transitionState= (TransitionState)o;
if ((this.positionA.equals(transitionState.positionA))
&&(this.positionB.equals(transitionState.positionB)))
{
return true;
}
}
return false;
}
@Override
public String toString() {
String output = "Position A " + positionA.i+ " "+ positionA.j + " "+ positionA.orientation + " "+
"Position B " + positionB.i + " "+ positionB.j + " "+ positionB.orientation;
return output;
}
}
class Position {
int i;
int j; …Run Code Online (Sandbox Code Playgroud) string aux;
int maxy,auxx=0;
cin>>aux;
maxy= (int)sqrt(aux.size());
Run Code Online (Sandbox Code Playgroud)
我在说:
1> error C2668: 'sqrt' : ambiguous call to overloaded function
1> could be 'long double sqrt(long double)'
1> or 'float sqrt(float)'
1> or 'double sqrt(double)'
Run Code Online (Sandbox Code Playgroud)
为什么?
a)在这种情况下,随机数发生器是否在每次运行时使用系统的时钟(进行种子更改)?
b)种子是否用于生成expovariate(lambda)的伪随机值?
我想做点什么
java -enableassertions com.geeksanonymous.TestClass
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?
这个矩阵转置函数有效,但我试图理解它的逐步执行,我不明白.
transpose:: [[a]]->[[a]]
transpose ([]:_) = []
transpose x = (map head x) : transpose (map tail x)
Run Code Online (Sandbox Code Playgroud)
同
transpose [[1,2,3],[4,5,6],[7,8,9]]
Run Code Online (Sandbox Code Playgroud)
它返回:
[[1,4,7],[2,5,8],[3,6,9]]
Run Code Online (Sandbox Code Playgroud)
我不知道连接运算符如何使用map.它是在同一函数调用中连接x的每个头?怎么样?
这是
(map head x)
Run Code Online (Sandbox Code Playgroud)
创建每个列表的头元素列表?
编译此代码时,我得到:
致命错误C1083:无法打开包含文件:'fstream.h':没有这样的文件或目录
为什么?
码:
#include <windows.h> // use as needed for your system
#include <gl/Gl.h>
#include <gl/glut.h>
#include <iostream>
#include <fstream.h>
//**************Global Data
char ifileName[30],oFileName[30];
fstream inFile,outFile;
//************ Data structure
struct GLfloatPoint
{ GLfloat x,y;
};
const int MAX = 100;
class GLfloatPointArray
{
public:
int num;
GLfloatPoint pt[MAX];
};
//***************** subprograms
typedef GLfloat colorType[3];
// subprogram used to draw the control points separately
void drawDot (GLfloat x, GLfloat y, GLfloat r, GLfloat g, GLfloat b)
{ glColor3f(r,g,b);
glBegin (GL_POINTS); …Run Code Online (Sandbox Code Playgroud) 我在Oracle SQL Developer上遇到以下错误:
Error starting at line 1 in command:
ALTER TABLE AEROPUERTO ADD CONSTRAINT AEROPUERTO_FK FOREIGN KEY (CODIGO_CIUDAD) REFERENCES CIUDAD(CODIGO)
Error report:
SQL Error: ORA-02298: cannot validate (SYSTEM.AEROPUERTO_FK) - parent keys not found
02298. 00000 - "cannot validate (%s.%s) - parent keys not found"
*Cause: an alter table validating constraint failed because the table has
child records.
*Action: Obvious
Run Code Online (Sandbox Code Playgroud)
为什么?
对于我的OS类,我应该只使用系统调用来实现Linux的cat(没有printf)
阅读此参考,我发现它被用于打印到文件.我想我应该操纵游戏.
在示例中出现: ofstream outfile ("new.txt",ofstream::binary);
如何将其写入屏幕?
编辑:我意识到这个write()是iostream库的一部分,这是否与int write(int fd,char*buf,int size)系统调用相同?
c++ ×3
java ×3
algorithm ×1
assertions ×1
c ×1
collections ×1
comparable ×1
comparator ×1
database ×1
equals ×1
haskell ×1
linux ×1
list ×1
netbeans ×1
oracle ×1
oracle10g ×1
python ×1
random ×1
seed ×1
system-calls ×1