Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x

C++

57K

Solutions

24K

Contributors

C++ is an intermediate-level general-purpose programming language, not to be confused with C or C#. It was developed as a set of extensions to the C programming language to improve type-safety and add support for automatic resource management, object-orientation, generic programming, and exception handling, among other features.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hello All,
I am trying a small sample Template code. I am getting linker error. I have declared and defined all the methods.
If I move the code from cpp to header then i dont see any linker error. Keeping them separate in header and CPP file is causing the issue. I am not sure what I am missing. I have attached the code for reference.
Please help me.
CodeFiles.zip
0
Free Tool: IP Lookup
LVL 11
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Hello,
I am trying to run this simple program in visual studio 2017 community edition and I am getting compilation error
Error      C2059      syntax error: '...'      

where am I going wrong here? Please help

#include "stdafx.h"
#include<iostream>

using namespace std;

template <typename ...Args>
void Printer(Args&&... args)
{
	(cout << ... << args) << endl;
}

int main()
{	
	Printer(1, 2, 3, "abc");
    return 0;
}

Open in new window

0
i would like to develop a page which can interact with AD so that user's can update their contact details on the fly and it's in sync with AD so that signatures are up to date. I also want to flash the page every 30/60 days to every user so that they are forced to check and update their contact

i have attached a layout , which i would like to create a page so that i can ask every user every now and then to update their contact details.
0
I would like to know how to fix the commented out code at line 20 so that I can std::copy a vector into a set. (I know I can copy the vector into the set using for-loops.) If this cannot be done, could you please explain why I am getting the error shown below.
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
   cout << "Hello World" << endl; 
   vector<int> v1(9,12), v1a(9,14);
   v1[0] = 99;
   
   copy(v1.begin(), v1.end(), v1a.begin() ); // no problem copy vector to vector
   cout << v1[0]  << " " << v1[1] << endl;
   cout << v1a[0] << " " << v1a[1] << " " << *(v1.begin()) << endl;

   set<int> s2( v1.begin(), v1.end() );
   set<int> s3;
//   copy( v1.begin(), v1.end(), s3.begin() );  // Compile error. How to std::copy from vector to std::set?
   
   set<int>::iterator sit = s2.begin(); // can increment this set iterator to get good results
   cout << s2.size() << " " << v1.size() <<  "   "  << *sit << "  " << *++sit << "  " << endl;
   
   return 0;
}

Open in new window


/* OUTPUT
Hello World
99 12
99 12 99
2 9   12  99  
*/

Open in new window


Even if you can fix the above error, would you mind interpreting the below error.
$g++ -o main *.cpp
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from main.cpp:1:

Open in new window

0
hi friends ,i am a beginner in c++ and i have some questions and i will be thankful if you help me to find its answers
1-a)a dynamic local variable has been declared in a function (method)
as below:
Work * p = new Work (p);

at the end of the function will this variable be released and erased (without making a call to its destroyer)?
b)if so: and if we call the destructor what will change?
------
2-And if we declare in its place a static variable:
Work p;

at the end of the function will this variable be released and erased?

-------------------------------------------------- -------------------------------------------------- ------------------
3-why do we prefer to work with a dynamic variable (and not a static variable) as a local variable?
0
Dear all,

I have an open code of MFC made in 2002. Could someone please tell me approximately which is the version of this script?

I imagine it is Microsoft C or Microsoft C++, but which version if was compiled in 2002?

Thanks

mfc.jpg
0
C++03 using VS 2010. (Assume no boost available.)

I would like to find the missing points in the below diagram using C++03 std lib. The x's represent a set of given points, and the o's are the missing points.

x----o--x----x---o
|    |  |    |   |
o----o--x----o---x
|    |  |    |   |
o----x--x----o---x
|    |  |    |   |
x----o--x----o---o
|    |  |    |   |
x----x--o----o---o
|    |  |    |   |
o----o--x----o---o

Open in new window

I am given a set of points Pi = (Xi, Yi). The coordinates are of type double. If I were to draw a grid (consisting of horizontal and vertical lines) going though every point, I may have some missing points as shown above.

The result should be a std container having the (X, Y) points that are missing.

I suspect that http://www.cplusplus.com/reference/algorithm/set_difference/ or some variation might be useful. So getting the entire list of potential points somehow is probably also useful. Although speed is always a plus, it is not essential.

Any code suggestions?

BTW - there are NOT going to be any tricky points - like a point very far away from the main set of points.
BTW - I've been using axis indices to represent the actual axis coordinate values (but don't worry about that if it complicates the code).

I can probably do this using brute force using a 2D array; so the purpose of this question is to use std lib algorithm functions to simplify the code and hopefully improve performance.
0
from the attachmet i need to print the output as

1.       class.User                                                                  

2.       class.User.mv.UserID                                             (mvè Member Variable)

3.       class.User.mv.UserPassword
0
I want to create a static class that will hold constants.  Then I want to create another class that can get the value of static class constants.

Can anyone provide a code sample?

Thx
0
I have an algorithm, written in MS C++ that I'm going to move to the cloud.  But I don't know a lot about cloud applications.  The plan is that I just work on my algorithmic code, and somebody else who is versed in cloud stuff will hook it up.   It was suggested that I modify my code into "a DLL that you call from within a web page hosted in IIS".   Can someone tell me what I might need to know about this?   Do you think I need to know anything about web or IIS to do this?  If I just format my code as a DLL that could be called by another C++ program (a test harness) - then should I be able to hand off that DLL to somebody else to stitch into the usage by "a web page hosted by IIS" ?  I would want to supply a DLL (not source code) with a published API that others can put "in the cloud".  Wondering if I need to know about web and IIS...
0
Technology Partners: We Want Your Opinion!
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

If some process takes too long (about 5 seconds) and the GUI can't refresh, Windows add the words "Not Responding" to the title bar of some or all windows.    Its been hard to figure out what is going on, but it seems this notification causes my MFC application to run the "OnSize" handler for the top most window (I suppose the one that got the "Not Responding" text added).  This is very annoying and was causing my App to crash until I wrote special code to try to determine if a given call to OnSize is legitimate or not -- if not I just return.  Now, at least, it doesn't crash -- but something in this process is taking a lot of time -- my App seems to freeze for a while to try to figure this all out, then resumes again.  Hard to figure out what is going on.  Anyone seen this before?
(btw - I know I should not have long processes in the GUI loop and they should be in a separate thread - and going thru my whole app and making sure that is true is one approach I'm working on, but I think this oddity can occur when some other process on the PC is taking a long time)
0
I have coded a Windows 32 VCL application using Embarcadero C++ builder  EX10.1 Berlin and using a winsoft TOBR barcode recognition component.
The application worked.
I now wish to no longer use the Winsoft component in the application so I removed it from the project entirely,including the library and the obr.hpp header file.
The project now compiles but I get a linker error that the file OBR.OBJ cannot be found when the project no loger uses the component as far as I can see.
Where is the linker getting the reference to OBR.OBJ from or how can I get rid of the error ?

The ilink32 command line is as follows :

  c:\program files (x86)\embarcadero\studio\18.0\bin\ilink32.exe -G8 -L.\Win32\Debug;"c:\program files (x86)\embarcadero\studio\18.0\lib\Win32\debug";
  CivicWeldRESTServer;"c:\program files (x86)\embarcadero\studio\18.0\lib\win32\release";"c:\program files 
  (x86)\embarcadero\studio\18.0\lib\win32\release\psdk";C:\Users\Public\Documents\Embarcadero\Studio\18.0\DCP -j.\Win32\Debug;"c:\program files 
  (x86)\embarcadero\studio\18.0\lib\Win32\debug";CivicWeldRESTServer;"c:\program files (x86)\embarcadero\studio\18.0\lib\win32\release";"c:\program 
  files (x86)\embarcadero\studio\18.0\lib\win32\release\psdk";C:\Users\Public\Documents\Embarcadero\Studio\18.0\DCP -l.\Win32\Debug -C -v 
  -GA"C:\Users\roger\AppData\Local\Temp\vfs7F41.tmp"="C:\Users\roger\Documents\Embarcadero\Studio\Projects\FrameStatusWebServerV2\WebModuleUnit1.dfm" 
  

Open in new window

0
VS2010 has a feature to "Restore Window Layout" to relay out all mainframe, menu, toolbars, and dockPanes, without restarting. How do I have my VS2010 wizard-generated MFC MDI app does this programmatically? Thanks.
0
I am getting a linker error when compiling an application with Embarcadero C++ Builder XE10.1 .
The application is a 32 bit windows VCL application (Web application). I can usually fix the error by re-booting the PC and running the compiler before any other application but recently this doesn't fix the problem.
The PC is a Dell precision 7710 with an Intel i7 2.7 Ghz processor and has 32 GB of RAM. the operating system is Windows 7 Professional 64 bit.
Looking around on the web, the issue would appear to be a buggy Embarcadero Linker which isn't going to be fixed any time soon.
Is there any solution to this ?

I have added the following option in the C++ Linker Additional options:   -GHtds=0x0F000000 and have also checked the  "clear state before linking" box in the C++ linker advanced options, neither of which actions has had any effect.

Any help appreciated.

Roger
0
I want to invoke login() method written in java.this login method requires one input parameter of type Consumer. Please find signature below.

 public void login(Consumer<String> consumerObj)
{
     ------------
}
In JNI implementation(C++ side) I need consumer like below.

env->CallVoidMethod(loginMethodClassID, loginMethodID,consumerObj);
I am not able to create consumerObj.

For your reference,sharing my java code snippet. In my Java Test class for invoking this same login method I do following.

Consumer<String> consumerObj= url ->
{
   webBrowser = new WebBrowser(url);
   webBrowser.start();
};
Application.login(consumerObj);
I know how to invoke login method but I need help on how i should create that consumerObj object.

Your help will be highly appreciated
0
I have recently learned C++ and C#. That is, I have taken courses to understand the basics of them and now want to start using them for professional work. I have said I want to take on projects that push me to learn a lot more about these vast programming languages. I have a hardware device name Griffin PowerMate. It is a USB knob/wheel that can be helpful controlling a computer. For some reason, it does not have great support on Window 7, 10. It does have a driver for Window XP and Vista. I cannot get this device to do what I want in Windows 10. However, on a Mac computer, the driver is up to date and does everything I want. So, to me this proves what I want on the Windows side is possible. Is it likely to think that without an SDK from the company I could use C++ or even C# to create a driver for this device?
0
Somewhere along the line, about when OOP came along, I was diverted into doing other things.  So, I lack the "cultural refinement" that must have come along with it.
I've written programs in C, C++, VBA, C#, and Fortran (of whatever recent vintage) but, I must admit, quit in starting on C# because there were all those class names that had no meaning for me.  I couldn't even debug an example program as a result!

I think I understand the general concepts - so that's not it.
It's the specifics that are elusive.
I've seen the same thing in VBA but seem to have been able to get things done.  It was sort of like "programming by example" as in "copy & paste".

I've researched it a bit but don't seem to find the answer.  So:
What is the key to understanding the Classes, what they're called and what they do, so that one can be relatively productive?  Does this come by osmosis?
It must be something like a dictionary....
Or, if the proper term is other than "Classes", can you enlighten me a bit please?
0
Reading and Writing CSV Files in MFC code

Files has to open in OpenOffice for the first Data. without closing the OpenOffice  ,In background  ,program s running and
datas has to saved in the CSV files. close the file and reopened the file .new data s has to updated.But only one data thats is also first data only in CSV file.(only in OpenOffice ,datas are not saved  while processing file should in open then  close the file  and reopened the same file,no datas updated )

code was working in CSV FIle Viewer and Notepad++ while opened while processing ,closed and reopened the same file, data are updated )
Plz help
0
#include <iostream>
void Triangle::move(float dx, float dy) {
    x+=dx;
    y+=dy;
}
void Triangle::zoom(float scale){
base*=scale;
height*=scale;
}
float Triangle::area(){
return base*height*(1/2);
}

int main () {
float t1, t2;
Triangle tri1, tri2;
tri1.move(12,0);
t1=tri1.area(); t2=tri2.area();
cout << "area: " << t1 << endl;
cout << "area: " << t2 << endl;
tri1.zoom(2.5);
t1=tri1.area();
cout << "area: " << t1 << endl;
}
This is my main cpp

class Triangle{
public:
    void move(float dx, float dy);
    void zoom(float scale);
    float area();
private:
    float x, y;
    float base, height;
};
This is my header file

I am currently practicing inheritance and polymorphism by myself so I picked up with easier one(which I think is drawing geometric shape) but it is quite harder than I thought. Can someone tell me how to change this with inheritance and polymorphism?
The other problem is that I also found this compiler called OpenGL which can literally draw shapes and I found that codeblock has the option for it. I really wanna try it out but I don't know how because it is not drawing anything even though I selected the option for OpenGL as project type.
0
What does it mean to be "Always On"?
LVL 5
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

I am writing a windows Web application using embarcadero XE10.2 Berlin C++ builder;
The application uses a TWebModule and receives a POST web action from a web page being displayed on a remote mobile device.
the mobile device posts a jpeg image which Is received in the following function, st2 is a TMemoryStream.
I am copying the raw content into a TByteDyneArray b so that I can easily inspect it. I load the TMemoryStream with the raw content and then save the memory stream to a file with the extension .jpg.
This file is reported as corrupt or invalid or too long when I try to open it with windows Photo viewer or the like.
how do I extract the image data ?
The size of the raw data as given by  Request->RawContent.Length is
Inspection of the beginning of the raw content  up to encountering a NULL is shown in quotes below.
"------WebKitFormBoundary9lWvgPDQcTZoDcRf\r\nContent-Disposition: form-data; name=\"picture\"; filename=\"15123250544981385201258.jpg\"\r\nContent-Type: image/jpeg\r\n\r\n�￘�£\x02tExif"

void TWebModule1::Action3Post(TWebRequest *Request,TWebResponse *Response)
{
	UnicodeString u,v,uu="";
	TByteDynArray b;
	char buff='a';

	int n,m,w;
	u = Request->ContentType;
	n = Request->RawContent.Length;
	m = Request->Files->Count;
	b = Request->RawContent;
	st2->Clear();
	b.set_length(n);
	st2->WriteData(Request->RawContent,Request->RawContent.Length);
    st2->Position = soBeginning;

//	Form1->Memo1->Lines =  Request->ContentFields;
	for(;;)
	{
		

Open in new window

0
Hello all,

Using Borland C++ 4.52 on a Windows Virtual PC in XP Mode.

I am writing what I thought to be a pretty simple DOS program.  It is basically opening files, filling up structures, printing structure information to a file and that's it.  The files are binary and are less than 32 Kbytes, most are 1K or less.   I am 75% of the way done, it has been running fine up to now.  I just added some code to finish it off, and now I am getting this error at runtime:

"The NTDVM CPU has encountered an illegal instruction.
CS:00cc IP:0106 OP:ff ff 00 00 00 Choose 'Close' to terminate the application."

The thing is, the code I added is just a repeat of the same code that was at the beginning but to different structures.  Seems to have something to do with the code size?  I don't know.  I am not that familiar with memory management.  However, when I removed the stuff I had added, it works again.  

I am attaching both the main code and the extra code I am trying to add.

I would appreciate any guidance.
extracode.txt
main-code.txt
0
I`m a manual Quality Assurance. I really need an automation in my hard work. How should I good start? Have you any ideas? I use Selenium and C++ at my work. But is a basic C++ enough? I was thinking to go to college to take some C++ credits there. Maybe there something like https://domywriting.com/ which could help me in my work. I`m really lost in it because I don`t have the Computer science degree.
0
I have a friend who wants to learn to make video games.

I was wondering what to teach him , I was thinking of starting out with Dennis Ritchie’s “The C Programming language”

He wants to make a game within the next two years. That’s his goal.
0
The skillset of programming makes the difference between having billions of operations per second in your lap and having billions of operations per second at your command. If you seek to partake, you may want to consider checking out my new course: https://www.experts-exchange.com/courses/1401/Programming-for-You-Introduction-to-C.html
1
I'm developing a game guard. And in the process, I want to read a packet and check its contents ... how should I do?

*(PDWORD)&OrigRecv = APIHook((DWORD)GetProcAddress(GetModuleHandle("Ws2_32.dll"), "recv"), (DWORD)MyRecv, (DWORD)OrigRecv);

Open in new window


my function recv

int WINAPI __stdcall MyRecv(SOCKET s, const char* buf, int len, int flags)
{
	int RecvedBytes = OrigRecv(s, buf, len, flags);
	if(RecvedBytes == SOCKET_ERROR) return RecvedBytes;

	eikasia_process_recv(s, (char *)buf, &RecvedBytes, flags); // Process the recived buffer
	return RecvedBytes;
}

Open in new window


My function process

void eikasia_process_recv(SOCKET s, char* buf, int *len, int flags) {
	unsigned int command = (*(unsigned short*)buf);


	if(command == 0x0363 ) {
 
     //reader buf data ...? read char* buf.... ?? help-me!

		}
	
}

Open in new window



When I find the packet I want to process, I want to read the contents of it to find the value I want. How to proceed?


my github: https://github.com/AsiaGenius/ring-0
0

C++

57K

Solutions

24K

Contributors

C++ is an intermediate-level general-purpose programming language, not to be confused with C or C#. It was developed as a set of extensions to the C programming language to improve type-safety and add support for automatic resource management, object-orientation, generic programming, and exception handling, among other features.