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

Hi! I've been programming for several years in Delphi, then C++Builder but recently I started programming concurrrently(threads)
I've read on documentation VCL should be used by "synchronice" method. My question: all of the objects from VCL should be
treated within a Synchronice call or only when severals threads use the same object or only when they affect the GUI(labels, buttons
and others properties)?. Suppose I have n threads but each one of them use their own objects(labels, tlistbox, etc) inside a TPage for each one, so there's a TPageControl for all of them should I use Synchronize?
0
I'm using currently the project
https://support.microsoft.com/de-de/help/246227/sample-secumgr-exe-overrides-security-manager-for-webbrowser-host
to check if a web portal, for example http://fontello.com/, works fine with EOT, WOFF and TTF to displaying different icons.

It looks like fonts with the Content-Type application/vnd.ms-fontobject or application/font-woff could not be used with IWebBrowser2.
In the webtraffic i could see, that the app could download the fonts, but after the download i received the error E_ABORT in the IHttpNegotiate::OnResponse handler.

The web pages works in IE, but when we disable font download in the security settings we get the same 'problem' with the IE.

I tried to enable the font download in function IInternetSecurityManager::ProcessUrlAction
(URLACTION_HTML_FONT_DOWNLOAD) without a positive result.

What i'm doing wrong?
0
#include <stdio.h>

int main (void)
{
    printf ("Hello, world!\n");
    return 0;
}


what does the  "\n" below mean ?

printf ("Hello, world!\n"
0
I am using C++03 in Visual Studio 2010 Express on Windows 10. If I were allowed to use C++11, I would just use C++11 threading model.

I found this link:
https://locklessinc.com/articles/pthreads_on_windows/
(I also found this another project: https://sourceware.org/pthreads-win32/index.html, but I'll deal with that later.)

Problem is, when I include the header from that link into my Linux pthreads program, I get lots of errors.
If you are interested in downloading it, use the above link and hit the download button on the left hand margin. Link is called "winpthreads.h".

I don't care if most of the header file is commented out. All I'd like to do is to get my old Linux pthreads program to work.

 I corrected some of them by including another header file, and declaring functions up front, so that they are known to the compiler when used in the header file. Here are the first couple of errors of many many errors:
1>c:\users\limited\documents\visual studio 2010\projects\multithreading\ode\winpthreads.h(212): error C3861: '_ReadWriteBarrier': identifier not found
1>c:\users\limited\documents\visual studio 2010\projects\multithreading\ode\winpthreads.h(218): error C3861: '_InterlockedCompareExchange': identifier not found
1>c:\users\limited\documents\visual studio 2010\projects\multithreading\ode\winpthreads.h(221): error C2440: 'initializing' : cannot convert from 'void (__cdecl *)(pthread_once_t *)' to 'void (__cdecl *)(void *)'
1>          None of the

Open in new window

0
Yes, I know main() is a function.  

Please keep in mind, I am taking a class on this and am not really looking for the "Answer".  More looking for understanding in what I have done wrong:

I am VERY new to this and HIGHLY confused so please be kind.

I need to create a function called computeTax.

It NEEDS to be BASIC.

This is what I have done ...yes I know its basic but Im just learning to crawl...:-)

/***********************************************************************
* Program:
*    
* Author:
*    
* Summary: 
*    This project will track my monthly budget and help me understand 
*    how to input data.
*    Estimated:  2.0 hrs   
*    Actual:     2.0 hrs
*      The most difficult part is getting testBed to behave
************************************************************************/

#include <iostream>
#include <iomanip>
using namespace std;
/************************************************************************
*ask user for income
************************************************************************/
//ask user for income

double getIncome()
{
   double income;
   cout << "\tYour monthly income: ";
   cin >> income;

   return income;
}

//Ask user for budget living expenses
double getBudgetLiving()
{
   double budgetLiving;
   cout << "\tYour budgeted living expenses: ";
   cin >> budgetLiving;
   
   return budgetLiving;
}
//ask user for actual living expenses
double getActualLiving()
{
   double actualLiving;
   cout << "\tYour 

Open in new window

0
I am using an open source project called yiimp which is for running a crypto currency pool. I am trying to add a new algorithm to the stratum. I can get it to build and the new algo to launch but when I add a coin to it it crashes with the segmentation error.

I can not for the life of me figure out whats causing the crash.   my public repo is at https://github.com/crombiecrunch/Yiimp-PHI1612-Implemented/tree/master/stratum/algos and the issues is with the equihash files.
0
I was a C++ developer years ago but switched to C# and never looked back. But I see so so many jobs as of late which are C++ jobs.

Are these high load website projects? I know that C++ is the fastest back-end language.

What kinds of systems are mostly using C++ lately?

What kinds of technologies and frameworks are most used today with the bulk of these C++ jobs? Is this typically c++ .NET?

Thanks.
0
How to do Windows 10 Microsoft Visual Studio 2010 Multihreading (but not .net and not MFC) in C++03.
I don't have 3rd party tools like openMP, etc. Just have native Microsoft API (I hope).

I searched around and found an answer to the following 3 questions (included in my post below):
When I search online, I found this:
Multithreading with C and Win32
https://msdn.microsoft.com/en-us/library/y6h8hye8.aspx

But I am in a 64-bit environment.

a. Is there a Microsoft 64-bit (non .NET) multithreading capability? If not, then I will proceed with 32-bit API. But the applications being developed are 64-bit.

b. Is it OK to use Win32 in the 64-bit application?

c. If it is OK, are there any performance penalties or any other downsides in doing this?

If you explain things to me, and use POSIX terminology and their Microsoft equivalent, that would help. I have done Linux multithreading. I am brand new to Microsoft development (other than using VIsual Studio 2010 for relatively simple single-threaded programs).

Unfortunately, I cannot use C++11 or Boost because they will not be installed for awhile (anywhere between 6-90 months is my best guestimate).

I am unable to install anything to enhance my development. (I know - this sucks.)

1. I would appreciate if you could provide good learning examples and help me with some questions on the basics if they arise.

Here are some links that I have just  quickly …
0
Any time that I click on the Factoring option on the main menu in a C++ builder project whilst in the code editor, the drop-down menu shows No Refactorings Available ? This is the same in RAD studio 10.2 C++ builder.
Is there a video tutorial showing how to use the Refactoring functionality or is it possible that it needs to be enabled somewhere ?
The written help on the subject just doesn't work on my PC.
0
We are examining options for our  VFP9 ERP software
1. Sacrifice the proprietary code and buy (rent) an existing package
2. Keep as is and cross fingers
3. Rewrite in C# or c++

In considering  #3--
I wrote the VFP9 software, and am nearing retirement. It's been running happily with no major issues for years now, needing only occasional tweaks to meet new needs. We've been training a fellow on a part-time contract basis in the system, and he is picking up VFP. He also has experience on other languages, particularly C#, and says that would be the way to go if we want to rewrite. I know nothing about either C# or C++, but a quick look on the web suggests C++ has more going for it.
This may end up in the Gigs section, but I'd like some views on this basic question--C# or C++. This is a single site manufacturing company--web forms are not a huge need. The system handles accounting, orders, inventory, shipping, EDI and scheduling. We would be converting to a Microsoft SQL Server.
0
I want to call a C++ project from Ruby, but my knowledge of the C build process is shaky at best, so unsure of how to set compiler flags (and why) as well as how to reference and link the project files. Currently RubyInline seems like the quickest option, but open to other suggestions.
0
I'm converting an old 32 bit dotNet application for use in a 64 bit environment.  The application GUI is VB, and the computational side is comprised of a set of DLLs written in Fortran.  At run-time the GUI loads the appropriate DLL using LoadLibrary and then locates the appropriate Fortran routine by calling GetProcAddress with the handle returned by LoadLibrary and the name of the Fortran routine.

This works fine in the original 32 bit environment (Windows XP), but when running as a 64 bit application (Windows 10) GetProcAddress fails to find the named routine, returning zero, following which GetLastError reports #126.  I am aware that a very common cause of this problem is failure to be aware of C++ name mangling, and have very carefully checked the routine names in the DLL using both Dependency Walker and Dumpbin and these do match the name being provided to GetProcAddress.

Though I'm not sure that it's relevant, there is one thing that distinguishes the Dumpbin output of the 64 bit DLL from that of the 32 bit DLL.  In the former case the names are shown in the form NAME = NAME.  In the Dumpbin listing of the 32 bit DLL the "= NAME" is missing.  I have attached copies of these two Dumpbin listings for reference.

Any guidance that is offered on how to resolve this problem will be greatly appreciated.

Thanks,
Randy
Dump64.txt
Dump32.txt
0
Starting with small C++ console program with one function call is there any examples of how to convert that to an equivalent VB.NET program. I don't want to use the VISUALBASIC namespace.

Thanks
0
I try to compile a code that was successfully compile on Linux system.  This code hast the usage of std::unique_ptr but Visual Studio nags arround the common C++ usage. The code looks like

    std::unique_ptr<bxf2::bxf> document = nullptr;
    ofstream cerr("output.txt");
    
    try
    {
        xml_schema::properties props;
        document = move(bxf2::bxf_(bxf_file, 0, props));  (Line 29)
    }

Open in new window


THe error message is:

1>XSDValidator.cxx(29): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'std::auto_ptr<_Ty>' (or there is no acceptable conversion)
1>          with
1>          [
1>              _Ty=bxf2::bxf
1>          ]
1>          C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\memory(2420): could be 'std::unique_ptr<_Ty> &std::unique_ptr<_Ty>::operator =(std::unique_ptr<_Ty> &&)'
1>          with
1>          [
1>              _Ty=bxf2::bxf []
1>          ]
1>          C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\memory(2449): or       'std::unique_ptr<_Ty> &std::unique_ptr<_Ty>::operator =(std::nullptr_t)'
1>          with
1>          [
1>              _Ty=bxf2::bxf []
1>          ]
1>          C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\memory(2520): or       'std::unique_ptr<_Ty> &std::unique_ptr<_Ty>::operator =(const std::unique_ptr<_Ty> &)'
1>          with
1>          [
1>              _Ty=bxf2::bxf []
1>          ]
1>          while trying to match the argument list '(std::unique_ptr<_Ty>, std::auto_ptr<_Ty>)'
1>          with
1>          [
1>              _Ty=bxf2::bxf []
1>          ]
1>          and
1>          [
1>              _Ty=bxf2::bxf
1>          ]

Open in new window


What I have done wrong in Visual Studio? IS Visual Studio the wrong version to use?
0
I have a short meta-programming approach for POD type safety from a previous question:
https://www.experts-exchange.com/questions/29056989/C-03-Templatize-Type-Safety-Enforcement-Part-2.html

I see the benefits of meta-programming as simplifying the development process for units - I believe that all new developers would have to do is to include a units header file, and follow a simple recipe for defining new data types.

I wrote in that question:
Other dimensional analysis areas that I am leaning towards:
 1. Make the class name part of the template
 2. Make the set of enumeration values part of the template so that they are not universally available
 3. Be able to operate on two different families of units. One obvious example would be:
        "distance (meters) = rate (meters/sec) * time (sec)".
     But we will have many other cross-unit operations as well.

I thought that I may as well see if I can get some tips on these ideas. If these 3 goals are realistic, but too much for one question, I am happy to work on what is reasonable for one question.

At the moment, I have to transcribe the previous question to my workstation, and then sell the ideas here and from the previous question to my lead software developer. The PM and Systems Engineer definitely like the idea of POD type safety. I just hope the lead likes the template approach.
0
How to insert image or picture in turbo c
Plz me
0
I have a short program shown below that is also located in:
https://www.experts-exchange.com/questions/29056211/C-03-Type-Conversion-Errors-for-primitive-types-Part-1.html#a42295035

I would like to templatize it to reduce the amount of tedium in handling multiple type conversions. I only show three types here (Hz, KHz, MHz), but I will be adding GHz as well. To make the classes easier to create, I got this good tip on the beginnings of templatizing the type enforcement/conversion classes:

What I would like to do is be able to handle the below program which has a bunch of friends and multiple implicit conversions for each type.

If I can get some meta-programming technique (or just plain templatizing) to generate lots of this type of code, I would greatly appreciate seeing how to do this. I'll be having to deal with many other families of types, such as distance: (feet, inches, millimeters, meters); time(seconds, hours - yes, I know about chrono); speed, etc.
#include <iostream>

class Hz
{
	friend class KHz;
	friend class MHz;
public:
	explicit Hz(double val) : val_(val) {}
	Hz(const KHz & khz);
	Hz(const MHz & mhz);
	double operator()() { return val_; }

private:
	double val_;
};

class KHz
{
	friend class Hz;
	friend class MHz;
public:
	explicit KHz(double val) : val_(val) {}
	KHz(const Hz & hz) : val_(hz.val_ / 1000.) {}
	KHz(const MHz & mhz);
	double operator()() { return val_; }

	KHz operator*(double mult)
	{
		return KHz(val_ * mult);
	}

private:
	

Open in new window

0
Can someone help me write this program in c++?

 Suppose a teacher weights the four exams he gives 10%, 25%, 30%, and 35%.
Write a program that reads ten sets of four grades, prints the weighted average of each set, and prints the unweighted average of each test. The number of students should be in a global constant.

I know I need to use a for loop, but I'm not sure how to write it. Can someone show me how to code this along with guiding me through the code?
0
NestingLayout.png
Here is my layout i need this in visual studio c# or c++ please help me to soft this problem. here i requested to give me idea to process layout like this,

thanks in advance
0
I am working on a project where I need to convert between units.
To avoid the Mars Landing mishap, I hoping to enforce enhanced typing of primitive types.
http://articles.latimes.com/1999/oct/01/news/mn-17288

For example, not all doubles representing length are meters; some are feet, or miles.
I don't want a function expecting meters to compile if it is given a double which is in feet.

The below program compiled in VS-2010 (C++03 required), but not in ideone.com
https://www.ideone.com/YGzOCy
(There is a chance that when I copied it incorrectly from VS 2010 to ideone.com.)
In the code below I have 3 comments indicating the problem areas I have.
Could you help me fix this program to address these 3 comments?
class Hz;
class KHz;


class KHz
{
public: KHz(double val) {val_ = val;}
	operator double() const {return val_;}
	KHz operator*(double mult) {return val_ * mult;}
	
private:
	double val_;
};


class Hz
{
public:
	Hz(double val) {val_ = val;}
	
private:
	double val_;
};


// 1. Would like to avoid this explicit conversion function:
Hz cnvKHzToHz(KHz khz) {return khz * 1000.0;}


void doSomething(KHz khz) {;}


int main()
{
	Hz ret = 0;
	KHz valkhz = 4.0;
	ret = cnvKHzToHz(3.0); // 2. Would like to have a compiler ERROR to prevent argument of double
	ret = cnvKHzToHz(valkhz);
	
	// doSomething(ret); // 3. ERROR: "Cannot convert parameter 1 from 'Hz" to 'KHz'
}

Open in new window

Thanks in advance.
Paul

p.s. - For more information on this topic, see:
https://www.experts-exchange.com/questions/29056989/C-03-Templatize-Type-Safety-Enforcement-Part-2.html
0
Platform: Windows 7 Professional SP1 64-bit
Currently have 64-bit version of "Microsoft Visual Studio 2010 Tools for Office Runtime" installed, have a new application that is failing to install. MSI log indicates it is missing the 32-bit version of the 2010 tools. So I downloaded the tools from Microsoft at: https://www.microsoft.com/en-us/download/details.aspx?id=54251

It downloads file "vstor_redist.exe", and when I install it it's log states "Visual C++ 2010" (see below). Ok, I kind of understand how they may be the same thing, however it never shows in the registry or add/remove programs as "Visual Studio 2010 Tools", and my 3rd-party application is still failing with the same error. So my question is, why does the vstor install show up as C++? And how can I go about finding a 32-bit installer that populates
the registry with the actual name "Microsoft Visual Studio 2010 Tools for Office Runtime (x86)"?


Error in MSI log for 3rd-party application:
 -- This application requires Microsoft Visual Studio 2010 Tools for Office Runtime. Please launch the install using setup.exe to install this requirement.
Note: I was never given an exe, only the MSI (that's prefered anyway since I am distributing via SCCM and/or BigFix)



Excerpt from vstor_redist.exe installation:

Patch (c:\8feb62db887aa9967092084220c26d74\VC_Red_x86\msp_kb2565063.msp) Install succeeded on product (Microsoft Visual C++ 2010 x86 Redistributable - 10.0.40219). Msi Log:
[9/8/2017, …
0
I have a sample application written in C++ for a slap scanner. I am able to get the image scanned but do not know what to do with the data received. Can anybody guide me in the right direction?

I have attached the SaveImage Code from the sample app(Written in C++) and would like to know how convert it to vb.net. I am novice when it comes to C++.

I have tried to read the bytes from memory starting at the pointer returned to the tagImageData structure during the scanning process.

here is the structure that contains the image data:
    <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> Public Structure tagImageData
        Public Buffer As IntPtr '< Pointer to image buffer
        Public Width As UInteger       '< Image horizontal size
        Public Height As UInteger      '< Image vertical size
        Public ResolutionX As Double  '< Horizontal image resolution (in PPI)
        Public ResolutionY As Double  '< Vertical image resolution (in PPI)
        Public FrameTime As Double    '< Image acquisition time (in seconds)
        '< This value contains the time taken for acquisition
        '< from device (excluding processing time).
        Public Pitch As Integer       '< Image line pitch (in Bytes).
        '  Positive values indicate top down line order,
        '  Negative values mean bottom up line order
        Public BitsPerPixel As Byte   '< Number of Bits per pixel
        Public Format As Integer      '< Image color format
       …
0
Hi EE.

Does anyone know how can I make my app to self delete? In VB.NET I use this:
Process.Start("cmd.exe", "/C ping 1.1.1.1 -n 1 -w 3000 > Nul & Del " + 
          Application.ExecutablePath); 
Application.Exit();

Open in new window

How can I also archive that in C++, I'm using Visual C++ 2010 Windows forms.
0
What technologies are best suited for the highest performance web services to handle the heaviest loads? Thousands (even millions) of transactions per second?

I know that Node.js can handle thousand(s) sessions on a single thread. And I do not know of any other technology which handle more than one session per thread. Am I right about that? Are there others that can do this also?

What about real-time programming as it relates to web-services. Is there such a thing?

And how about a few general words about hardware deployment? Having a central API call which distributes calls to hundreds of more specialized web servers? What about Caching for successive related calls?

And what about Machine Learning? Can algorithms be optimized by existing Machine Learning algorithms that reduce the average response times of the most heavily load web service?

Thanks.
0
I have a dialog that is derived from our specific base class that is inturn derived from CDialog class
This dialog contains a combobox with combobox items in it (string)
There is a group box, labels, checkbox and a text box as well (I will call them grouped controls for this discussion)
If I select an item in index 0 from combo box, the Grouped controls are shown and if I select an item in index 1 from combo box, the group controls should be hidden
I have used the code to show or hide the controls as
void MyDerivedClass::HideMyControls(bool hide)
{
	int param = (false == hide)? SW_SHOW : SW_HIDE;
	
	CWnd* pCtrl = GetDlgItem(IDC_ENABLE_TP_DIRECTORY);	
	CRect myRect;
	pCtrl->GetClientRect(myRect);	

	GetDlgItem(IDC_STATIC_NOTE)->ShowWindow(param);//This is label control
	GetDlgItem(IDC_STATIC_DIR_NAME)->ShowWindow(param);//This is label control
	GetDlgItem(IDC_EDIT_TP_DIRECTORY)->ShowWindow(param);//This is text control
	GetDlgItem(IDC_STATIC_TP_GRPBOX)->ShowWindow(param);//This is label control
	InvalidateRect(myRect);	
	UpdateWindow();
}

Open in new window

The issue is the controls are still seen on the screen even after the above method is called with true parameter. If I move some other window on top of the (supposed to be) hidden controls, then it is actually disappears. So this seems to be a refresh issue. My assumption is that the InvalidateRect and UpdateWindow should have taken care of repainitng this. but is not happening.
Tried with InvalidateRect(NULL) to paint the whole screen, but still no use.

Could you please suggest how I can hide the controls? any clean way of doing this?

Note: when the controls are (supposed to be) hidden but are still seen on the screen, I will not be able to perform any action on those controls (like setting checkbox or typing in the text box).
So I believe that the controls are marked as hidden but not painted.
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.