Interview Question in Visual Studio 2008
Interview Question :: VS2008 compiling error need suggestions |
1>------ Build started: Project: Lab5, Configuration: Debug Win32 ------
1>Compiling...
1>Disk.cpp
1>c:\users\devy's phantasy\desktop\lab5\disk.cpp(30) : error C2511: 'bool Disk::isInside(const GLfloat,const GLfloat)' : overloaded member function not found in 'Disk'
1> c:\users\devy's phantasy\desktop\lab5\disk.h(9) : see declaration of 'Disk'
1>Build log was saved at "file://c:\Users\Devy's Phantasy\Documents\Visual Studio 2008\Projects\Lab5\Debug\BuildLog.htm"
1>Lab5 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped =======
//Disk.h
#ifndef DISK_H
#define DISK_H
#include "ApplicationWindow.h"
#include "Drawable.h"
#include "Color.h"
class Disk : public Drawable
{
public:
Disk(GLfloat x, GLfloat y, GLfloat radius, Color color)
: radius(radius), color(color) { pos[0] = x; pos[1] = y; }
void draw() const;
bool isInside(const GLfloat x, const GLfloat y) const;
private:
GLfloat pos[2];
GLfloat radius;
Color color;
};
#endif
//Disk.cpp
#include <cmath>
#include "Disk.h"
#include "Drawable.h"
void Disk::draw() const
{
glEnable(GL_BLEND);
glColor4fv (color.v);
GLfloat x1 = pos[0];
GLfloat y1 = pos[1];
glBegin(GL_TRIANGLES);
for(int i = 0; i <= 360; i++)
{
GLfloat angle = (GLfloat)(((double)i) / 57.29577957795135);
GLfloat x2 = pos[0] + (radius * (GLfloat) sin((double)angle));
GLfloat y2 = pos[1] + (radius * (GLfloat) cos((double)angle));
glVertex2f(pos[0], pos[1]);
glVertex2f(x1, y1);
glVertex2f(x2, y2);
y1 = y2;
x1 = x2;
}
glEnd();
glDisable(GL_BLEND);
}
bool Disk::isInside(const GLfloat x, const GLfloat y)
{
double distanceSquared = (x - pos[0]) * (x - pos[0]) + (y - pos[1]) * (y - pos[1]);
return distanceSquared < radius * radius;
} |
|
|
|

Loading ...