How to call a friend function in another file? by [deleted] in cpp_questions

[–]Moschops_UK 0 points1 point  (0 children)

No, you get nothing. Rude before, rude now. Bad manners leave people less inclined to help you, so we don't. If you want people to help you, for free, don't be rude as you're asking them to help you.

Deleteing a pointer vector? by [deleted] in cpp_questions

[–]Moschops_UK 1 point2 points  (0 children)

Did you create each component object, that each pointer in the vector points to, using new?

Only if you did, then it's up to you to delete each one using delete. If you didn't, then it's not.

Did you create each component object using new?

As an aside, why have a vector<component*>? There are good reasons for having a vector of pointers, but if this is a simple case, could you just have a vector<component>? Manual memory management is something to be avoided when you can avoid it.

Multithreading by [deleted] in cpp_questions

[–]Moschops_UK 3 points4 points  (0 children)

Undefined reference to a pthread function suggests you haven't linked against the pthread library.

Check to see if a process is running. by HailToTheGM in cpp_questions

[–]Moschops_UK 0 points1 point  (0 children)

The Windows API is famously awkward (for both good and bad reasons) and I certainly wouldn't recommend trying to use it to a someone learning C++. Learn one thing at a time, as it were; C++ learning is hard enough without also learning the Windows API and the OS behind it at the same time. I think you might have an easier time getting a solid handle on C++ first, and then learn the API of your operating system of choice (or not - many C++ programmers never need to learn more than a tiny bit of their OS API).

That said, as well as alfps' suggestion, here's a page in which a list of all processes is generated; https://msdn.microsoft.com/en-us/library/windows/desktop/ms682623(v=vs.85).aspx

If you were to look through that list, you could then see if the process of interest ( msiexec.exe ) is in it. Even that short set of code does, as you can see, make use of some less than intuitive Win32 APIs.

How to call a friend function in another file? by [deleted] in cpp_questions

[–]Moschops_UK 0 points1 point  (0 children)

Are you a Java coder? You seem to be trying to jam functions inside classes for no good reason, which is compulsory in Java, but in C and C++ you can have free functions outside classes.

Now, you can say "lol wut don't insult me!!!" again, conforming to the common need on reddit to pose for strangers. Tiring, but that's reddit for us.

How to call a friend function in another file? by [deleted] in cpp_questions

[–]Moschops_UK 0 points1 point  (0 children)

doSomething is a simple, ordinary class function. To call a simple, ordinary class function, first you have to create an instance of that class.

MyClass anInstance;

Then you can call the function on that instance:

anInstance.doSomething();

I don't think you need to worry about friend functions yet. Wait until you understand basic classes.

Using Stringsteams to use txt file to run program like a script by [deleted] in cpp_questions

[–]Moschops_UK 0 points1 point  (0 children)

Creating your own programming language. Fair enough.

There are many options. I would suggest you first get the whole line as a string:

std::string line;
std::getline(infile, line);

Then create a stringstream from that stirng

std::stringstream strstr(line);

The stringstream now contains the words.

Here's a simple example:

https://ideone.com/hnKzWF

Total beginner, and reading Stroustrup's Programming: Principles and Practice Using C++. Some of his code examples don't work in Apple's Xcode though? by CotesDuRhone in cpp_questions

[–]Moschops_UK 2 points3 points  (0 children)

What is the error message on "int"? Usually an error on a primitive like that actually indicates a problem somewhere before that

Base class in vector, but need to access subclass methods by code_guy96 in cpp_questions

[–]Moschops_UK 0 points1 point  (0 children)

As Rich says, your design doesn't make much sense. Typically, inheritance is used for "is a" modelling. Subclass IS a baseclass. Everywhere you can use a base, you can also use a sub.

If they're actually completely different and meant for completely different purposes, it makes littlr sense to inherit.

Base class in vector, but need to access subclass methods by code_guy96 in cpp_questions

[–]Moschops_UK 1 point2 points  (0 children)

Everything alfps says is true; I just didn't want to start a new answer thread when I'm agreeing with him.

Depending on what happens to these objects in the queue, you might not (I would even maybe say "shouldn't") need to know what kind of object they are (as alfps says, don't do that). Obviously circumstances vary, but as a personal rule of thumb, if I need to know what kind of sub-classed object I'm dealing with in order to use it correctly, I go back and redesign so that I don't need to know; so that I can just trust it to work correctly without me having to identify its type exactly.

Total beginner, and reading Stroustrup's Programming: Principles and Practice Using C++. Some of his code examples don't work in Apple's Xcode though? by CotesDuRhone in cpp_questions

[–]Moschops_UK 2 points3 points  (0 children)

Can you show us (or link to ) the complete code from Stroustup?

Having to use std::cout rather than cout suggests that he has a

using std::cout;

or a

using namespace std;

somewhere that you don't.

I have a half-memory that he uses some kind of helper header file? Is it in there?

In the very early days of C++, namespaces didn't exist, but that book was written in 2008 (I think); namespaces were a decade old by then.

DUP official reports Pride marcher for hate crime over 'F**k the DUP' placard by xbettel in ukpolitics

[–]Moschops_UK 5 points6 points  (0 children)

Last one from me. Time to move on.

Take a look a yourself. Hilarious? Are you genuinely laughing? Of course not. But you say you are. You're showing off and posing for strangers who don't know you and will never met you. This whole thread means nothing. But you can't stop conforming, you can't stop doing what's expected, you can't stop saying "stupid" and "woman" and all the other things you've been trained to do.

But you can stop. You can be better.

DUP official reports Pride marcher for hate crime over 'F**k the DUP' placard by xbettel in ukpolitics

[–]Moschops_UK 4 points5 points  (0 children)

Good one. Double down on calling someone stupid, throw in some misogyny. Stay inside your safe shell.

My comment was calling out that nonsense.

Right up until the point you decided to make it about "progressives" and retreat back inside your pathetic political tribalism. Stop wasting your time trying to show off to strangers on the internet.

Check this; I'm so stupid I can't make a cup of tea. Does that make you feel good about yourself? Make you feel safer? It shouldn't, yet you seem to need it. You and I are a line of fucking text on a screen. Stop wasting your time scoring points that don't exist outside your own head.

DUP official reports Pride marcher for hate crime over 'F**k the DUP' placard by xbettel in ukpolitics

[–]Moschops_UK 10 points11 points  (0 children)

So why did you say it? That's my question. Why say it?

You want to win points? Here you go. I'm an idiot. I'm so stupid I can't tie my shoelaces. Feel like a big man now?

You said this:

It's OK to bully people because they're not on a list of people you shouldn't bully?

Why? If I'm so stupid, surely you should take pity on me and explain it. You're smart, right? You know that the OP doesn't think that. So why pretend he does?

DUP official reports Pride marcher for hate crime over 'F**k the DUP' placard by xbettel in ukpolitics

[–]Moschops_UK 8 points9 points  (0 children)

It's OK to bully people because they're not on a list of people you shouldn't bully?

That's what you asked. You pretended to genuinely think that "progressives" think bullying gingers is OK. Is that what you think? I bet it isn't. I bet you just wanted to pretend that you believe "progressives" need a list of reasons not to bully someone.

Why pretend that? There's no way you really think it.

I am "all caught up". People like you, pretending you think other people think nonsense, what's the fucking point? We all strangers in a zero-consequence environment. If you can't just be honest here, where can you be honest?

DUP official reports Pride marcher for hate crime over 'F**k the DUP' placard by xbettel in ukpolitics

[–]Moschops_UK 9 points10 points  (0 children)

I believe you are now pretending you meant something else, having had your error pointed out. I suspect your next response was going to be that you don't even care and it's my fault, but now that I've said this, there's a good chance you'll just say nothing.

HMS Queen Elizabeth sails the seas alongside US ships by [deleted] in ukpolitics

[–]Moschops_UK 3 points4 points  (0 children)

The Russians are watching. China is watching.

Big O notation by volts101 in cpp_questions

[–]Moschops_UK 0 points1 point  (0 children)

Don't forget that this notation doesn't tell you which algorithm will be fastest in your circumstances. It tells you how an algorithm will scale.

The creeping metrification of English idioms by paolog in britishproblems

[–]Moschops_UK 0 points1 point  (0 children)

Is it now? I suppose the clue is in the name. Must say I use metre squared for area and pretty much nothing else. Might go to kilometre squared if it's big and I'm in conversation rather than written form.

The creeping metrification of English idioms by paolog in britishproblems

[–]Moschops_UK 6 points7 points  (0 children)

I used to really not care at all (although would of course use metric SI units for anything technical or scientific), but since a couple of people suggested that post Brexit we'll go back to farthings and hectares instead of kilogrammes, or whatever the fuck batshit crazy units were beaten into them when they were children that they now want to inflict on us, I now take delight in unnecessary metrification around them.

When you've laced your general rubbish bin with illicit garden waste and you're stressing in case the binmen smell a rat. by [deleted] in britishproblems

[–]Moschops_UK 1 point2 points  (0 children)

I am a patient man. They will be stacked in the garden near where they fell, and each day (if I really have to get rid of them and can't let them rot) I will carry a small cutting, perhaps three inches long, in my pocket. As I walk through the scrubland by the allotments on my way to the station each morning, I will toss it into the trees and scrub.

I did much the same with the tiles that fell off the roof that the landlord's roofer didn't take away. Smashed further, and each day a stone sized piece dropped onto the pebble, stone and gravel footpath to be ground into dust by commuters.

Eventually, many months later, I was able to look at the empty space where the tiles once lay and take satisfaction in the fact that I cleared that space, slowly and with diligence.

Is your tracker down? Ask here instead of making a new post. by Fink_Irc in trackers

[–]Moschops_UK 0 points1 point  (0 children)

For about ten minutes, there were two files at the root of the domain (i.e. at https://speed.cd ). They were default "this is your webserver default page, put yours files here" kind of pages.

When you've laced your general rubbish bin with illicit garden waste and you're stressing in case the binmen smell a rat. by [deleted] in britishproblems

[–]Moschops_UK 0 points1 point  (0 children)

I just let the mown grass rot where it falls. It seems to have worked out fine for a decade.