|
Quote: And as such, a vector may contain objects, or pointers to objects
But when you add a class object, the vector doesn`t make a copy of the object, it creates a pointer to the object being added. A linked list deals with pointers not objects.
|
|
|
|
|
If you add an object to an STL container (vector , list , set , map ...), the object is copied into the container. The objects must all be of the same type, however. The only way to put polymorphic objects into a container is to use a container of pointers to their common base class, in which case the objects need to survive outside the container, probably by having been allocated from the heap.
modified 16-Apr-22 7:34am.
|
|
|
|
|
thanks Greg, I`ll keep that in mind.
|
|
|
|
|
CalinNegru wrote: when you add a class object, the vector doesn`t make a copy of the object, it creates a pointer to the object being added. No, the vector copies whatever type you have declared it with. For example:
std::vector<std::string> myVec;
std::string newstr = "A string";
myVec.push_back(newstr);
CalinNegru wrote: A linked list deals with pointers not objects. Well sometimes it does; but what has that to do with this question?
|
|
|
|
|
ok, I think I get your point
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
|
You are trying to dereference the BDADDR_ANY structure. You should just take the value, which is already the address.
loc_addr.rc_bdaddr = BDADDR_ANY;
|
|
|
|
|
// Server side C/C++ program to demonstrate Socket programming
#include <unistd.h>
#include <stdio.h>
#include <sys socket.h="">
#include <stdlib.h>
#include <netinet in.h="">
#include <string.h>
#define PORT 8080
int main(int argc, char const *argv[])
{
int server_fd, new_socket, valread;
struct sockaddr_in address;
int opt = 1;
int addrlen = sizeof(address);
//int addrlen;
char buffer[1024] = {0};
char *hello = "Hello from server";
// Creating socket file descriptor
if ((server_fd = socket(AF_INET, SOCK_STREAM, 0)) == 0)
{
perror("socket failed");
exit(EXIT_FAILURE);
}
// Forcefully attaching socket to the port 8080
if (setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR | SO_REUSEPORT,&opt, sizeof(opt)))
{
perror("setsockopt");
exit(EXIT_FAILURE);
}
address.sin_family = AF_INET;
address.sin_addr.s_addr = INADDR_ANY;
address.sin_port = htons( PORT );
// Forcefully attaching socket to the port 8080
//if (bind(int sockfd, const struct sockaddr *addr,
// socklen_t addrlen)<0))
//if (bind(int server_fd,(const struct sockaddr *)&address,sizeof(address))<0)
if (bind(server_fd, (struct sockaddr *)&address,sizeof(address))<0)
{
perror("bind failed");
exit(EXIT_FAILURE);
}
if (listen(server_fd, 3) < 0)
{
perror("listen");
exit(EXIT_FAILURE);
}
if ((new_socket = accept(server_fd, (struct sockaddr *)&address,
(socklen_t*)&addrlen))<0)
{
perror("accept");
exit(EXIT_FAILURE);
}
valread = read( new_socket , buffer, 1024);
printf("%s\n",buffer );
send(new_socket , hello , strlen(hello) , 0 );
printf("Hello message sent\n");
return 0;
}
|
|
|
|
|
Your code compiles fine on my Linux box (GCC 9.4 ).
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
|
You are welcome.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
System.DirectoryServices.dll file has been added successfully to Visual C++ MFC project through References in Solution Explorer.
Microsoft Development Environment 2003 Version 7.1.3088.
Microsoft .Net Framework 1.1 Version 1.1.4322
using namespace System::DirectoryServices;
void CClassName::MethodName(){
...
DirectorySearcher* directorySearcher = new DirectorySearcher();
directorySearcher->ClientTimeout = 60000;
...
}
file.cpp(1701): error C2061: syntax error : identifier 'DirectorySearcher'
file.cpp(1701): error C2065: 'directorySearcher' : undeclared identifier
file.cpp(1701): error C2065: 'DirectorySearcher' : undeclared identifier
file.cpp(1702): error C2227: left of '->ClientTimeout' must point to class/struct/union
type is ''unknown-type''
file.cpp(1268): error C2653: 'System' : is not a class or namespace name
file.cpp(1268): error C2871: 'DirectoryServices' : a namespace with this name does not exist
file.cpp(1702): error C3861: 'directorySearcher': identifier not found, even with argument-dependent lookup
By this way I need to set Request Timeout for SOAP WebService
modified 2-Apr-22 8:04am.
|
|
|
|
|
|
It is .Net:
Microsoft Development Environment 2003 Version 7.1.3088.
Microsoft .Net Framework 1.1 Version 1.1.4322
Visual C++ MFC:
When I add to References System.DirectoryServices.dll it refuses to add not 1.1.4322 version of it,
only System.DirectoryServices.dll of 1.1.4322 version
|
|
|
|
|
.Net is for managed C++/CLI.
MFC does nt support "managed" code, only the native one. So you have to create a new C++/CLI project and try to work with this DirectorySearcher class in there.
|
|
|
|
|
Can you think about the problem to implement the use of DirectorySearcher class?
I have System.DirectoryServices.dll suitable exactly for my version of Microsoft .Net Framework 1.1 Version 1.1.4322.
Other versions of System.DirectoryServices.dll are refused to be added to the References folder in the project.
About to upgrade software that will be suitable to new Visual Studio version - it not so simple.
It is huge old software. I has performed conversion today but can not yet to see the result today. There were errors that conversion raised during it
|
|
|
|
|
|
Plus, let's not forget the "bible" of native/managed interop, C++/CLI in Action[^] by our friend Nish.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I seriously recommend upgrading Visual Studio to latest and use a version of the .NET Framework that hasn't been dead for the last 10 years.
|
|
|
|
|
About to upgrade software that will be suitable to new Visual Studio version - it not so simple.
It is huge old software. I has performed conversion today but can not yet to see the result today. There were errors that conversion raised during it
|
|
|
|
|
So my app works using MFC toolbar creation without issue. If I set a flag, I can make it Dock or Float when the program is started using m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); . The code that does it lives in the OnCreate which of course can only be called once. What I'm looking to do is use my property sheet to allow the user to select the mode of the toolbars Docked or Floating which requires a method outside of the OnCreate . So I have two buttons for testing, one to destroy the toolbar (working) and create which "rebuilds" the toolbar....
I start off with the app in the Docked mode, then I test by destroying the toolbar and then rebuilding it. The rebuild is where my issue is. On the rebuild , it is "adding" some blank space equivalent to the two toolbars (Menu and Button ) and the toolbars float ....I can drag it out of where it was docked.....and the floating bar works.....but it "leaves behind" the a non functional version of the floating toolbar where it was once docked. If I double click the floating bar, it jumps back to its previously docked location.
So I'm trying to figure out what is needed to correct my code that partially does what I want.....and fix the artifacts.
The code to destroy:
int CMainFrame::OnToolBarDestroy()
{
CDockingManager myPane;
myPane.RemovePaneFromDockManager(&m_wndToolBar, TRUE, TRUE, TRUE, NULL);
m_wndToolBar.Invalidate();
m_wndToolBar.DestroyWindow();
myPane.SaveState();
CPaneContainer myContainer;
myContainer.RemoveNonValidPanes();
RecalcLayout();
return 0;
}
The code to rebuild the toolbar:
int CMainFrame::OnToolBarCreate()
{
if (m_wndToolBar)
{
m_wndOutput.AddStringStatusTab(_T("Error: Icon toolbar is already active, action cancelled"));
m_wndOutput.AddStringDebugTab(_T("Debug: MainFrame--Error: Icon toolbar is already active, action cancelled"));
return -1;
}
CMFCPopupMenu::SetForceMenuFocus(FALSE);
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to Create Dialog ToolBar\n");
return -1;
}
CMFCToolBar myTools;
myTools.IsFloating();
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndToolBar);
EnableAutoHidePanes(CBRS_ALIGN_ANY);
CRect rcClientOld;
CRect rcClientNew;
GetClientRect(rcClientOld);
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0, reposQuery, rcClientNew);
m_wndOutput.AddStringStatusTab(_T("I'm created 1 times"));
m_wndToolBar.ShowPane(TRUE, FALSE, TRUE); RecalcLayout();
return 0;
}
In the rebuild, note the comment of where the problem begins.....If I comment out that line.....I can destroy and rebuild the toolbar with no issue, it is once I enable that line of code which creates the "float" of the toolbar action. I thought by destroying the toolbar and rebuilding it with the same options as the OnCreate function with the float line mentioned above would do it.....but I get weird issues with the toolbar.
Here are images showing:
Docked Menu:
http://kittmaster.com/imagedump/codeproject/Toolbar1.png
Destroyed Toolbar:
http://kittmaster.com/imagedump/codeproject/Toolbar2.png
Rebuilt Toolbar with issues described:
http://kittmaster.com/imagedump/codeproject/Toolbar3.png
Any ideas how I can solve this issue?
I can't find any code examples anywhere the float option isn't done outside of the OnCreate function.
Hopefully someone can guide me?
You can see with all the commented code of things I've tried to see if I could fix it...
Thanks in advance!
Chris
|
|
|
|
|
Hi,
I haven't used the MFC classes in nearly a decade but maybe I can help you debug it.
kittmaster wrote: but it "leaves behind" the a non functional version of the floating toolbar where it was once docked. My instincts are telling me that the non-client area[^] has expanded down when your CControlBar was created.
Can you check for this for me? You can get the non-client area by calling GetWindowRect [^] and subtracting the GetClientRect[^].
If I am correct then you will need to send the WM_NCCALCSIZE message[^] to reclaim your top client area.
Best Wishes,
-David Delaune
|
|
|
|
|
|
Well,
Your Debug window is showing a 39 pixel difference on the Y axis, so the client area size has certainly changed.
Go through the CControlBar documentation to make sure there isn't a built-in way to avoid the non-client area resizing. I don't remember off the top of my head.
If not then maybe use a sledge hammer to fix it by sending a WM_NCCALCSIZE to resize it manually.
Best Wishes,
-David Delaune
|
|
|
|