|
Great that helps a lot. I now am using:
int** q = new int*[rows];
for(int i = 0; i < rows; i++)
q[i] = new int [col];
This works.
MSDN states "Multidimensional arrays are not equivalent to arrays of pointers." It seems that here this code is creating just that. I suspect this is why I don't see the elements in the Autos window. I will play around with this for a while and will post new questions later.
Thanks for the help.
If only I had more time!
|
|
|
|
|
You can always create multi dimensional arrays by arrays of pointers pointing to another array. The difference I think is basically in memory locations, creating arrays by this method dynamically may not have continous memory locations, like that by creating arrays like int a[5][5];
http://www.priyank.in/
|
|
|
|
|
Hi ,
Is there any Static address in computers in a local network?
Like the MAC Address But I want to send Information to it.
Cheers,
Thanks.
|
|
|
|
|
dSolariuM wrote:
Is there any Static address in computers in a local network?
IP addresses are either statically or dynamically assigned.
dSolariuM wrote:
Like the MAC Address But I want to send Information to it.
Are you wanting to send information to an IP address or a MAC address?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I want to send information to MAC address.
Thanks.
|
|
|
|
|
Have a win32 console application, when I right click on it the version tab is missing.
How do I add this information?
ThankX in advanced
|
|
|
|
|
Just add a Version resource to it. Click on the ResourceView tab in the Workspace pane. Use Ctrl+R to insert a new resource. Select Version from the list.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Add a resource file (*.RC) to your project.
Add a version information resource to the resource file.
|
|
|
|
|
I add a rich edit control from controls tool box, when I run my project, it appear a message box "Failed to create empty document"
What is this error ?
Could you give me an example how to create a rich edit control ?
Thank you.
|
|
|
|
|
Have you called AfxInitRichEdit() ?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Why do we need to use this function ?
Thank you.
|
|
|
|
|
You might not need to, unless this is an MFC application. It was merely a suggestion. Do you know for certain that it is not needed?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Because it will enable/initialize the richedit support.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hi everybody,
I have created an PopUp Menu in a CDialog...it works OK.
Now I want to create a PopUp Menu inside an ActiveX every time I click Button RIGHT of the mouse...
I have copied the code inside the function WM_RBUTTONDOWN...The problem is that it shows the Menu but it is DISABLED (it is shown but I can not select an option).
How can I do it to solve it...to make it enable?
Thanks
Javier
|
|
|
|
|
The menu items will be disabled until you write the code for the menu items. When the handlers are written, then the menu items will be enabled.
Artificial intelligence is no match for natural
stupidity.
Never argue with an idiot. They will drag you down to their level where they are an expert.
|
|
|
|
|
But...I have already written the handlers...or at least...this is what I think
I enclose the code here :
HMENU hMenu = ::CreatePopupMenu();
if (NULL != hMenu)
{
// add a few test items
::AppendMenu(hMenu, MF_ENABLED | MF_STRING & !MF_GRAYED, 1, "Change Color");
::AppendMenu(hMenu, MF_ENABLED | MF_STRING & !MF_GRAYED, 2, "Hide");
::AppendMenu(hMenu, MF_ENABLED | MF_STRING & !MF_GRAYED, 3, "Item 3-");
ClientToScreen(&point);
int sel = ::TrackPopupMenuEx(hMenu,
TPM_CENTERALIGN | TPM_RETURNCMD,
point.x,
point.y,
m_hWnd,
NULL);
CString s;
s.Format("The selected item is %d", sel);
TRACE(s);
::DestroyMenu(hMenu);
}
Thanks
|
|
|
|
|
javi_jmc wrote:
::AppendMenu(hMenu, MF_ENABLED | MF_STRING & !MF_GRAYED, 1, "Change Color");
Do you have a function that the application would call when you click the "Change color" menu item? If not, that's what you need to do. Without a function to call, the menu item will be disabled.
Artificial intelligence is no match for natural
stupidity.
Never argue with an idiot. They will drag you down to their level where they are an expert.
|
|
|
|
|
But...why do I need a function to call ? I have "sel" which gives the value of the item selected. With "sel", I can manage the selection with, for instance, a CASE
But...if it is not possible and I have to do it as you are saying...how can I link a function to a selection?
Thanks you very much.
|
|
|
|
|
javi_jmc wrote:
But...why do I need a function to call
I hate to tell you this, but that's the way it is. When you click on a menu item, that's an event that the application will receive. If the app isn't going to handle the events then the menu items won't even be enabled. There's nothing to map the events to so there isn't any sense in enabling the menu item. Your case statement won't handle the menu event.
|
|
|
|
|
OK, so I have a header file which I call NewTypes.h that has definitions for several struct s. In particular, I have a struct PPLoutput , and I have overloaded the << operator so I can output it easily. The signature I am using for the operator is:
std::ostream& operator<<(std::ostream& s, const PPLoutput& p);
If I have the definition for this function in the header file, then I get the errors at the bottom (all files compile cleanly. I am having problems in the linking phase). Of course, I need to have NewTypes.h #include d in multiple files. I have two multiple-include guards (#pragma and #ifndef ). So, the file looks like:
#pragma once<br />
<br />
#ifndef NEWTYPES_H<br />
#define NEWTYPES_H<br />
<br />
<br />
<br />
struct PPLoutput<br />
{<br />
<br />
};<br />
<br />
std::ostream& operator<<(std::ostream& s, const PPLoutput& p)<br />
{<br />
<br />
};<br />
<br />
#endif
If I move the definition of operator<< to a different file (Combo.cpp ), then it compiles and links fine. How do I get it to link while keeping it in NewTypes.h ? I am using Visual Studio .NET 2003.
Errors below:
Combo.obj : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __fastcall operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,struct PPLoutput const &)" (??6@YIAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABUPPLoutput@@@Z) already defined in 3PLComboDlg.obj
ComboDlg.obj : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __fastcall operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,struct PPLoutput const &)" (??6@YIAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABUPPLoutput@@@Z) already defined in 3PLComboDlg.obj
LNP.obj : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __fastcall operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,struct PPLoutput const &)" (??6@YIAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABUPPLoutput@@@Z) already defined in 3PLComboDlg.obj
LNPDlg.obj : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __fastcall operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,struct PPLoutput const &)" (??6@YIAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABUPPLoutput@@@Z) already defined in 3PLComboDlg.obj
Release/3PLCombo.exe : fatal error LNK1169: one or more multiply defined symbols found
--
Marcus Kwok
|
|
|
|
|
|
Thanks. I tried cleaning and then rebuilding but I still get the same error.
|
|
|
|
|
Hello,
Your problem is clear! You should separate the definition of functions from the declaration. The definition (aka implementation) should be in a compilation unit (*.cpp file) the declaration should be in the header file.
if you separate those, you should have no problem.
I also got the blogging virus..[^]
|
|
|
|
|
Thanks, that worked. So, if I have the declaration in the header file but the implementation in the cpp file, then any file that includes the header file should be able to see the function?
--
Marcus Kwok
|
|
|
|
|
The problem was that your #ifdefs only protect against the header being included multiple times from the same source file. Since it is being included multiple places in your project, std::ostream& operator<< is getting defined multiple places, and therefore compiled into many different .OBJ files. The linker does not like this when it tries to tie it all together.
When you separate the header and implementation, the CPP file with the function definition gets compiled only once, so the linker is happy.
|
|
|
|