remove or replace duplicated C++ code in one function on Linux [closed] - c++

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am working on C++ on Linux.
I need to remove some duplicated code in two functions.
One function is for computing and another one is for logging.
There are some code that are duplicated in logging(), which is much longer than computing().
The duplicated code is distributed in logging() separately, which means that they are not just copy and paste from computing().
I need to figure out the duplicated part line by line, remove them and then replace the necessary results by passing them as parameters from computing() to logging.
Are there some efficient ways to handle this ?

Look at the functions side by side, identify common blocks of code, then factor these common blocks out into separate methods/functions.

It might not be worth merging them. If you really have to, though, perhaps one common function with an extra bool do_logging parameter.

Related

Implementation of vector of integers with overloaded operators, fails to run properly [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I have huge problems with making this code work properly.
http://pastebin.com/Mi6gj188
There's an output from example program on the bottom. It simply crashes and doesn't deliver proper results too. It seems that none of the overloaded operators work as it should
You didn't write a copy constructor, or use RAII. As a result, every time your vector object is copied (and it is, a lot, because you make no use of references!!) your internal data pointer is copied, sharing it amongst multiple objects (each of which will attempt to delete it on destruction) causing a horrible bug.
Your book tells you about the rule of three, which you should now go ahead and work on following.

Family tree structure in c++ [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to make a program that gets the information of a family including their names, SSN etc. I'm facing with two problems, firstly, what is the best data structure for this purpose,secondly, how should i get the information from the user, i mean when I'm getting info of father,i should determine his children, here is the problem.
how to connect his children to himself?
If it were me, I'd create a few different parallel arrays.
You're going to need to find out the algorithms for search through the arrays.
You're going to need to find out how to match them up together using the same index once the search finds a match. The index will probably be needed to be returned by reference to make things easier.
How to connect the children to the father maybe harder...
I don't know much about Binary Trees, we never talked about those in class. But that maybe the answer you're looking for. Sorry I couldn't be of more help. It's Christmas and it's 3AM lol. Good luck.

Informatica : Sequence generate [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Without using sequence generator How can we generate sequences in informatica mapping ?
Thanks
Well, like others said, I would have preferred to get a specific question on why you are trying to avoid sequence generator. Having said that, if i open myself to "the idea of an alternate" to sequence generator, some things do come to mind
If you have a relatively simplistic mapping, you can embed a oracle/db sequence.nextval call hidden in the source qualifier.
you can embed db/sequence call in a sql tranformation too. But know that it would be anti-performant.
you will be able to achieve a sequence generator behaviour using a persistent variable too, but there are limitations and downsides.
So, again, depending upon what you are trying to do and where you are getting stuck, you might want to repost/edit your question.. and perhaps get a more direct answer.

C++ multiple process shared memory implementation [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Here's what I am trying to accomplish.
I want program1 to create a shared memory segment where I store various arrays.
Then, I want program2 to read in the arrays and modify them.
This sounds pretty simple, but for some reason, I cannot find a single example online that shows how this is done. Every example I have found uses a single program (e.g the initialize, read and write are both done by program1).
If somebody can provide an example here, I'm sure this would be hugely beneficial for pretty much everybody that wants to use IPC in C++.
Boost.Interprocess has a guide for the impatient.

Haskell function which takes a list and return tuples [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I have ordederd to make a function, which takes a list ex [3,4,6,1,29] and returns a list of tuples [(3,4),(4,6),(6,1),(1,29)]
This is a very easy question, it's really hard to help without defeating the purpose...
If you are allowed to use predifined functions, there is already one which can do almost all work for you (if you don't know which one, try finding it with http://www.haskell.org/hoogle/ ). Take a step back and think about the easier question how to produce a list [(3,3),(4,4),(6,6),(1,1),(29,29)].
If you can't use predefined functions, then recursion is your friend: What do you need to do for an empty list? What for a list with one element? With two elements?
Without any own effort I can't give more hints. If you're stuck, extend your question and show what you already got, and we'll try to help.