|
Take a look at documentation for the CDatabase and CRecordset MFC classes.
I believe this will be the easiest for a beginner.
In particular look at the CDatabase::Open[^] method.
|
|
|
|
|
Hi
How could I write my xml document with indention By MSMXL6
Is there any way to cofigure this
a sample code my clear the case
regards
|
|
|
|
|
The only way i've been able to do this was to apply a XSL transform to the XML before saving it using the transformNodeToObject method of MSXML.
Good luck.
M.
Watched code never compiles.
|
|
|
|
|
Hi,
would any one where I can download or define a cursor such as the one in VIsual Studio uses when stepping thru code ???
also that round bullet used to signify breakpoint is nice dont know if that something I can define and or Load from my resource file
thankx
|
|
|
|
|
The ordinary VS project setup that installs some application on computer does not delete files that were changed during program usage.
If installing that setup again on the same computer those files are not replaced with those from setup either.
How to enable setup to remove all files from and folders in spite the files were changed or added others?
Чесноков
|
|
|
|
|
a.h: static ClassOne *one;
a.cpp: ClassOne::one = this; //So, can I do it like this?
But an error has occured: "expected constructor, destructor, or type conversion before '=' token"
modified on Thursday, April 15, 2010 9:54 PM
|
|
|
|
|
In a.cpp, try:
ClassOne *one = this;
What was I thinking?
modified on Thursday, April 15, 2010 10:44 PM
|
|
|
|
|
If I understand what you are asking, then it should be something like this:
- a.h
class ClassOne {
void SetRef();
};
static ClassOne* one;
- a.cpp
one(0);
inline void ClassOne::SetRef() {one = this;}
Your problems are:
- "this" is only valid inside class member methods.
- You do not need to have "ClassOne::" infront of "one" unless it is a static member of the class (it is declared within the scope of the class).
If "one" is a static member, this a.cpp would be as follows:
ClassOne * ClassOne::one(0);
inline void ClassOne::SetRef() {ClassOne::one = this;}
|
|
|
|
|
It seems you are confusing classes with instances (that is the same as confusing types with variables) local and global scope and linkage.
Assuming the declaration you provided are at file scope (that is, not enclosed in some other braces) one is a pointer to a ClassOne object. It exist at global level (the pointer!) and have only local visibility (local in respect to the cpp file that "sees" it, that are all the cpp files that include the h file - in other words, static has very few sense in h files)
ClassOne::one does not exist, since one is global, and not a part of ClassOne (hence the compiler doesn't know what to do), and than, this is meaningless since you are not inside a member function body.
At this point we cannot correct, since we cannot figure out what you where trying to do.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
if you need a global object create one. If not you dont need a global pointer.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
I have to display the contents of a binary tree in its "tree" form rather than a string of numbers.
I have a solution(i think) on how I'm suppose to display it.
My problem is that I keep getting a link error that looks like this:
"b11.obj : error LNK2001: unresolved external symbol "public: void __thiscall AVLTreeType<int>::rnl_inorderTraversal(void (__cdecl*)(int ..."
I know its the display hierarchy component of the program specifically, but I don't know what.
I'm using Visual Studio 08.
Thanks in advance.
and sorry for the long post.
I just thought people would at least want the functional parts of the binary tree class code.
here's most of the binary tree class code:
at the very bottom is the rnl_inorderTraversal function I'm having trouble with.
#include <iostream>
using namespace std;
template<class T>
struct AVLNode
{
T info;
int bfactor;
AVLNode<T> *llink;
AVLNode<T> *rlink;
};
template <class T>
class AVLTreeType
{
public:
void insert(const T &newItem);
void postorderTraversal(void (*visit)(T&) );
void rnl_inorderTraversal(void (*visit)(T&,int));
int treeHeight();
int treeNodeCount();
int treeLeavesCount();
void destroyTree();
AVLTreeType();
private:
AVLNode<T>* root;
void rotateToLeft(AVLNode<T>* &root);
void rotateToRight(AVLNode<T>* &root);
void balanceFromLeft(AVLNode<T>* &root);
void balanceFromRight(AVLNode<T>* &root);
void insertIntoAVL(AVLNode<T>* &root,AVLNode<T> *newNode, bool& isTaller);
void rnl_inorder(AVLNode<T> *p,void(*visit)(T&,int),int);
void postorder(AVLNode<T> *p, void (*visit)(T&) );
void destroy(AVLNode<T>* &p);
};
template<class T>
void AVLTreeType<T>::rotateToLeft(AVLNode<T>* &root)
{
AVLNode<T> *p;
if(root == NULL)
cerr<<"Error in the tree."<<endl;
else
if(root->rlink == NULL)
cerr<<"Error in the tree:"
<<" No right subtree to rotate."<<endl;
else
{
p = root->rlink;
root->rlink = p->llink;
p->llink = root;
root = p;
}
}
template<class T>
void AVLTreeType<T>::rotateToRight(AVLNode<T>* &root)
{
AVLNode<T> *p;
if(root == NULL)
cerr<<"Error in the tree."<<endl;
else
if(root->llink == NULL)
cerr<<"Error in the tree:"
<<" No left subtree to rotate."<<endl;
else
{
p = root->llink;
root->llink = p->rlink;
p->rlink = root;
root = p;
}
}
template<class T>
void AVLTreeType<T>::balanceFromLeft(AVLNode<T>* &root)
{
AVLNode<T> *p;
AVLNode<T> *w;
p = root->llink;
switch(p->bfactor)
{
case -1: root->bfactor = 0;
p->bfactor = 0;
rotateToRight(root);
break;
case 0: cerr<<"Error: Cannot balance from the left."<<endl;
break;
case 1: w = p->rlink;
switch(w->bfactor)
{
case -1: root->bfactor = 1;
p->bfactor = 0;
break;
case 0: root->bfactor = 0;
p->bfactor = 0;
break;
case 1: root->bfactor = 0;
p->bfactor = -1;
}
w->bfactor = 0;
rotateToLeft(p);
root->llink = p;
rotateToRight(root);
}
}
template<class T>
void AVLTreeType<T>::balanceFromRight(AVLNode<T>* &root)
{
AVLNode<T> *p;
AVLNode<T> *w;
p = root->rlink;
switch(p->bfactor)
{
case -1: w = p->llink;
switch(w->bfactor)
{
case -1: root->bfactor = 0;
p->bfactor = 1;
break;
case 0: root->bfactor = 0;
p->bfactor = 0;
break;
case 1: root->bfactor = -1;
p->bfactor = 0;
}
w->bfactor = 0;
rotateToRight(p);
root->rlink = p;
rotateToLeft(root);
break;
case 0: cerr<<"Error: Cannot balance from the right."<<endl;
break;
case 1: root->bfactor = 0;
p->bfactor = 0;
rotateToLeft(root);
}
}
template<class T>
void AVLTreeType<T>::insert(const T &newItem)
{
bool isTaller = false;
AVLNode<T> *newNode;
newNode = new AVLNode<T>;
newNode->info = newItem;
newNode->bfactor = 0;
newNode->llink = NULL;
newNode->rlink = NULL;
insertIntoAVL(root, newNode, isTaller);
}
template<class T>
void AVLTreeType<T>::insertIntoAVL(AVLNode<T>* &root,
AVLNode<T> *newNode,
bool& isTaller)
{
if(root == NULL)
{
root = newNode;
isTaller = true;
}
else
if(root->info == newNode->info)
cerr<<"No duplicates are allowed."<<endl;
else
if(root->info > newNode->info)
{
insertIntoAVL(root->llink, newNode, isTaller);
if(isTaller)
switch(root->bfactor)
{
case -1: balanceFromLeft(root);
isTaller = false;
break;
case 0: root->bfactor = -1;
isTaller = true;
break;
case 1: root->bfactor = 0;
isTaller = false;
}
}
else
{
insertIntoAVL(root->rlink, newNode, isTaller);
if(isTaller)
switch(root->bfactor)
{
case -1: root->bfactor = 0;
isTaller = false;
break;
case 0: root->bfactor = 1;
isTaller = true;
break;
case 1: balanceFromRight(root);
isTaller = false;
}
}
}
template <class T>
void AVLTreeType<T>::postorderTraversal(void (*visit)(T& item) )
{
postorder(root, *visit);
}
template <class T>
void AVLTreeType<T>::postorder(AVLNode<T> *p,
void (*visit)(T& item) )
{
if(p != NULL)
{
postorder(p->llink, *visit);
postorder(p->rlink, *visit);
(*visit)(p->info);
}
}
template <class T>
void AVLTreeType<T>::destroy(AVLNode<T>* &p)
{
if(p != NULL)
{
destroy(p->llink);
destroy(p->rlink);
delete p;
p = NULL;
}
}
template <class T>
void AVLTreeType<T>::destroyTree()
{
destroy(root);
}
template<class T>
AVLTreeType<T>::AVLTreeType()
{
root=NULL;
}
template<class T>
void rnl_inorderTraversal(void(*visit)(T&,int))
{
int iLevel=0;
rnl_inorder(root,*visit,iLevel);
}
template<class T>
void rnl_inorder(AVLNode<T> *p,void(*visit)(T&,int),int)
{
if(p != NULL)
{
iLevel+1;
rnl_inorder(p->rlink,*visit,iLevel);
(*visit)(p->info);
rnl_inorder(p->llink,*visit,iLevel)
}
}
here's the code for main.
specifically, the areas which rnl_inorderTraversal is used.
#include <iostream>
#include <iomanip>
#include"avlTree.h"
#include <fstream>
using namespace std;
template<class T>
void displayHierarchial(T& anItem, int level);
int main()
{
AVLTreeType<int> cTree1;
cTree1.insert(1);
cTree1.insert(2);
cTree1.insert(4);
cTree1.rnl_inorderTraversal(displayHierarchial);
return 0;
template<class T>
void displayHierarchial (T& anItem, int level)
{
cout <<level<<".) "<< anItem<<' ';
}
|
|
|
|
|
template<class T>
void rnl_inorder(AVLNode<T> *p,void(*visit)(T&,int),int){
if(p != NULL)
{
iLevel+1;
rnl_inorder(p->rlink,*visit,iLevel);
(*visit)(p->info);
rnl_inorder(p->llink,*visit,iLevel)
}
}
Should be:
template<class T>
void AVLTreeType<T>::rnl_inorder(AVLNode<T> *p,void(*visit)(T&,int),int){
if(p != NULL)
{
iLevel+1;
rnl_inorder(p->rlink,*visit,iLevel);
(*visit)(p->info);
rnl_inorder(p->llink,*visit,iLevel);
}
}
To fix the error you posted. You forgot to tell it that this is the definition for a method of that class. Also I put in a missing semicolon.
|
|
|
|
|
The whole time I thought it was something else, I didn't think to even question my syntax.
Thanks a lot!
|
|
|
|
|
CWinApp::WinHelp doesn't work for Mobile CE 6.0 target apps ( VS 2009), neither does the HTML Help. Anyone with experience on how to launch help from Pocket PC apps?
|
|
|
|
|
You could use CHtmlView or IE to open *.html .
You have also to split your *.chm (if any) to the *.html firstly
virtual void BeHappy() = 0;
|
|
|
|
|
I would like to combine a simple menu of two items and a simple toolbarof two icons as well into same bar.
right now m_wndCommandBar.InsertMenuBar(IDR_MAINFRAME) and m_wndToolBar.LoadToolBar(IDR_MAINFRAME) will create them on two different bars? How can I combine?
Note, I used to be able to do this in previous versions of Visual Studio by ::InsertButtons(...)
Thanks
|
|
|
|
|
|
|
In my MFC application 1 parent thread and multiple (not fixed) child thread are there.
CWinThread **Thread;
UINT parent()
{
....
int cnt=0;
....
Thread[cnt]=(CWinThread*)malloc(CWinThread));//access violation
while(block>0)
{
Thread[cnt]=AfxBeginThread(...);
cnt++;
Thread[cnt]=AfxBeginthread(..);
cnt++;
}
....
// for wait -- WaitForMultipleObjects is called for cnt
}
|
|
|
|
|
You should first make room for the pointers, i.e.
Thread = (CWinThread **) malloc( sizeof(CWinThread *) * MAX_COUNT);
sksksksksksksks wrote: malloc(CWinThread));
Are you sure you can do that?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
If you are using C++ (CWinThread is a class), why are you mixing it with C (using malloc) ? You should use new/delete instead.
|
|
|
|
|
Why do you need an array of threads? What are you trying to achieve?
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
It's a new design pattern, firsty introduced here[^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
we need a name, "throw more threadz at a problem to get more solutionz" is too long
|
|
|
|
|
Moak wrote: is too long
But it is really good!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|