|
Hey Everyone. My problem is it seems that when I create a .cpp file for a .hpp, when dealing with inheritance, I get the same error which is :
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.hpp(20) : error C2146: syntax error : missing ';' before identifier 'GeoGroup'
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.hpp(20) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.hpp(20) : error C2470: 'GeoGroup' : looks like a function definition, but there is no parameter list; skipping apparent body
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.hpp(20) : error C2059: syntax error : 'public'
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(14) : error C2653: 'GeoGroup' : is not a class or namespace name
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(15) : error C2270: 'draw' : modifiers not allowed on nonmember functions
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(16) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(16) : error C2228: left of '.size' must have class/struct/union
5> type is ''unknown-type''
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(18) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(18) : error C2227: left of '->move' must point to class/struct/union/generic type
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(18) : error C2065: 'refpoint' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(19) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(19) : error C2227: left of '->draw' must point to class/struct/union/generic type
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(20) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(20) : error C2227: left of '->move' must point to class/struct/union/generic type
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(20) : error C2065: 'refpoint' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(27) : error C2653: 'GeoGroup' : is not a class or namespace name
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(32) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(32) : error C2228: left of '.begin' must have class/struct/union
5> type is ''unknown-type''
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(32) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(32) : error C2228: left of '.end' must have class/struct/union
5> type is ''unknown-type''
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(33) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(33) : error C2228: left of '.end' must have class/struct/union
5> type is ''unknown-type''
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(35) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(35) : error C2228: left of '.erase' must have class/struct/union
5> type is ''unknown-type''
here is an example of what I am trying to get complied:
the header file
#ifndef GEOGROUP_HPP
#define GEOGROUP_HPP
#include "geo.hpp"
#include <vector>
namespace Geo
{
Class GeoGroup : public GeoObj
{
protected:
std::vector<GeoObj*> elems;
public:
GeoGroup(const Coord& p = Coord(0,0)) : GeoObj(p)
{
}
virtual void draw() const;
virtual void add(GeoObj&);
virtual bool remove(GeoObj&);
virtual ~GeoGroup()
{
}
};
}
#endif //GEOGROUP_HPP
and the dotC file:
#include "geogroup.hpp"
#include <algorithm>
namespace Geo
{
void GeoGroup::draw() const
{
for (unsigned i = 0 ; i < elems.size(); ++i)
{
elems[i]->move(refpoint);
elems[i]->draw();
elems[i]->move(-refpoint);
}
}
bool GeoGroup::remove(GeoObj& obj)
{
std::vector<GeoObj*>::iterator pos;
pos = std::find(elems.begin(), elems.end(), &obj);
if (pos != elems.end())
{
elems.erase(pos);
return true;
}
else
{
return false;
}
}
}
This seems to me to be a linking problem, and also I realized that I might have something to do with having multiple .hpp and multiple .cpp implementation files.
Anyone have an idea on what I am doing wrong?
Thanks,
RobNO.
|
|
|
|
|
The keyword class should have a lower-case 'c'.
|
|
|
|
|
Thank you very much
RobNO
|
|
|
|
|
RobNO wrote: This seems to me to be a linking problem
when the first error message says "missing ;" it is a compiler error, not a linking problem.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
An often ocurring syntax error: a class declaration should end with a semicolumn.
class C {
} void f(){
}
|
|
|
|
|
I have an HMENU that shows a typical context menu.
What I want to do is make a large context menu like win98 start menu.
Any particular method?
|
|
|
|
|
Check out this[^] article, it might be usefull.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
I don't work with MFC. Is there a way to do it in C within the native API?
|
|
|
|
|
Well, since MFC is just a wrapper around the API, i'd say yes, in my oppinion what you need is an owner drawn menu, i think this[^] should help.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
|
Hi,
In Internet Explorer, when I click on a link and go back to the previous site I am exactly at the same position of the document where I left. Even the link I clicked is still marked by a thin border.
I have an application where I keep track on the history on my own. Now I need exactly the same behaviour.
I think i need to save the "state" (scrollposition and "marked" link) in my history array and restore it afterwards when I load the old site again.
Does anybody know how to achieve this?
If this is hopeless it would also be enough to just save to current (scroll-)position. However, the loaded documents are complex with different divs which have overflow:auto, overflow:hidden etc. So I can't just get_body, query IHTMLTextContainer and afterwards get_scrollTop etc. because those would be the scroll stuff from the document itself...
Thank you for any hints!
|
|
|
|
|
I want to create a dll which can create custom controls like custom dialog and custom button etc..
Can anybody tell me how to do that..
Please help me regarding this..
Thanks
|
|
|
|
|
As with most things, break the problem down into smaller parts.
Can you make a DLL?
Are you thinking of MFC? In which case, export a CMyWnd class, and do RegisterWindowClass (*) in the constructor.
If it's win32, take a leaf out of InitCommonControls, and export a function from your dll that registers the windows classes.
The first two parts have good articles here on CP.
You also need to work out what the problem you are solving is - that will have a big effect on your solution.
Iain
(*) from memory. Look up appropriate function!
I have now moved to Sweden for love (awwww).
|
|
|
|
|
Ys I can create the DLL but I want to know how we can add the custom class for the Button which is drived from CButton in the DLL, so that I can use that dll in my sdi application to create the button.
Thanks,
|
|
|
|
|
OK, so you can make a DLL.... Check.
And this is in MFC... Check.
So, there's only a few simple things to do:
1/ Make a header somewhere that both the dll code, and the later exe code can read. (I have a workspace include directory, normally).
Near the top, have code like this:
#ifdef IAINDLL
#define IAINEXPORT __declspec(dllexport)
#else
#define IAINEXPORT __declspec(dllimport)
#endif
When you write your CButton inheriting class, start like this:
class IAINEXPORT CIainButton : public CButton
{
};
In your project settings, make sure to add the following symbol to the defines: IAINDLL. That way, when code in the DLL sees the header file, it says "oh, this will be exported!", and when code elsewhere sees the header file, it says "aha, I will link to these class functions".
If you don't know how to write a custom CButton class, then Button Controls[^] is full of examples for you to follow.
Good luck,
Iain.
I have now moved to Sweden for love (awwww).
|
|
|
|
|
Hi,
I want to write an addin for visual studio, that will display a tooltip showing a certain datamember, when I hover the mouse over a MyClass object f.ex. Is this at all possible? I don't know how to get the information about what the mouse is hovering over. I need some links to reference docs. Thanks!
modified on Tuesday, May 18, 2010 8:32 AM
|
|
|
|
|
_Worksheet objSheet;
Range objRange;
-----------some code here----------------
objRange = objSheet.GetRange(COleVariant(A1),COleVariant(K4));
//at the following line I got the memory leak memory of my programme get increase
ret = objRange.GetValue2();
How to solve that problem
Trioum
|
|
|
|
|
How do you know there is a leak? What are the types of the variables?
Steve
|
|
|
|
|
_Worksheet objSheet;
Range objRange;
-----------some code here----------------
// code to obtained the excel sheet pointer
objRange = objSheet.GetRange(COleVariant(A1),COleVariant(K4));
//at the following line I got the memory leak memory of my programme get increase
ret = objRange.GetValue2();
As I call the ret = objRange.GetValue2(); memory occupied by exe getting increased.
I see in task manager -> process . I have a timer of 1 second which poll data every secong form the excel file . if I do not start timer then there is no memory increase in excel file .
Trioum
|
|
|
|
|
Hello everybody,
I created a service which runs nicely on my local machine.
If I like to test an existence of a file, which is located on a network-folder (net use g: \\...)
then the function _access returns me -1 (not exists).
If I call exactly the same function with the same filename in a standard application (not as a service)
then all works fine.
Is it an access-security problem, or do I use simply the wrong function to test the existence of a file?
(I don't wanted to use a fopen,fclose)
Big thanks for any ideas
|
|
|
|
|
what account is your service running under - default localsystem ?
if so, you'll need to change that so that the account you run under has network access (localsystem by default does not have network access, this includes shares iirc).. create a dedicated account for your service, give it the correct access, its better than localsystem
(if you google around a bit you should find more pointers on the same)
'g'
|
|
|
|
|
If your service runs under the local system/local service account, it has no rights to access network resources.
Try the network service user or create a new user and assign the login to this service.
Greetings
Covean
|
|
|
|
|
Big thanks for your replies.
That seems logic, but it doesn't work ... it's seriously a configuration problem.
I'll make a workaround
Thanks you two
|
|
|
|
|
Try to see what GetLastError returns immediately after the call to __access, it might tell you something. There's a tool in Visual Studio that will give you the error text for each error id.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hello
I want to make a timer in maze.The timer should countdown to reach 0 and if the player doesn't reach to end he/she lose the game.
I want to denote that if player reach to end timer should stopped working.
How can I do it?
Thanks anyone help me.
|
|
|
|