« first day (147 days earlier)      last day (2708 days later) » 

12:57 AM
if have a template class that i want to use as the type for another template how do i by pass the infinite nesting that the IDE is asking me to do
if have a template class that i want to use as the type for another template how do i by pass the infinite nesting that the IDE is asking me to do
 
1 message moved from Lounge<C++>
@chewbapoclypse I don't speak with IDEs. They never ask me to do anything. SSCCE?
 
I'm not joking.
I'm just pointing out that your question doesn't make sense to me.
 
ok well let me show you from pastbin one second
 
So, what would that code do?
(What is OnDiskArray<File<File> >, logically or functionally speaking?)
 
1:13 AM
its a file of files, one file that multiple files
if that makes sense...
 
What is that, physically?
A directory? A zipfile?
@chewbapoclypse I'm afraid not
 
yea that is a good description
zipfile
 
@chewbapoclypse So. What do you want to store there? Just the descriptions of a file?
And what operations do you want. Is this is homework assignment?
I think you're stuck on the wrong track at all. When are you going to use Student?
And do you realize that using reinterpret_cast to serialize it like that is pure nonsense? You can't usefully read back a char* in that way.
 
i have complete the assignment now i am experimenting, but help is always welcome
nd do you realize that using reinterpret_cast to serialize it like that is pure nonsense? You can't usefully read back a char* in that way... I am not sure I follow
its works for the things i have tested
OnDiskArray<int> intfile("IntFile", 5);
intfile.Set(0, 50);
int x = intfile.Get(0);
cout << x << endl;
intfile.Set(0, 25);
x = intfile.Get(0);
cout << x << endl
 
@chewbapoclypse And those things did not include char*, like your Student
 
1:22 AM
OnDiskArray<char*> cstrfile("CstrFile", 5);
cstrfile.Set(0, "name");
cstrfile.Set(1, "age");
char * cstr = cstrfile.Get(0);
cout << cstr << endl;
cstr = cstrfile.Get(1);
cout << cstr << endl;
that worked
and the int
 
Erm. Yeah. Because it doesn't do anything.
Try reading it back after restarting the application.
 
like open the file again and read it out?
 
Well. The point is to make it so that the char* don't point to those literals anymore.
What compiler are you using anyways? That shouldn't compile because "name" cannot be converted to char* (it can decay to char const* if you must)
(inb4 Turbo-C++ or DevC++)
 
VS 2015
 
Then you need to enable warnings
Also, I asked about the compiler and you answered with an IDE. I presume you're using MSVC compiler
 
1:26 AM
yup
 
@chewbapoclypse coliru.stacked-crooked.com/a/8d35923ff655254a - note I had to print the output as hex, so you can see the corrupt data at all
 
hmmm... that is a very interesting site
i had similar problems when i first ran it it had to do with closing and reopening the streams
 
it's not that. Anyhoops. The whole thing is flawed. And smells like bad C from the 1980s. Are you trying to learn C++ for real? Post it on Code Review - but only the short sample (e.g. with strings).
If you're just trying to pass a course to get through college, and you will not be using C or C++ in real life, ... well. Your choice.
But be sure you never use C or C++ for real then. Because otherwise, it's irresponsible.
 
yea in my book it says that "Using reinterpret_cast is compiler dependent and can cause programs to behave differently on different platforms."
but there was no other way that it suggested to return the type of information that you read in
 
1:42 AM
@chewbapoclypse It's worse. It's [UB] here
In computer programming, undefined behavior (UB) is the result of executing computer code the behaviour of which is not prescribed by the language specification to which the code adheres, for the current state of the program (e.g. memory). This happens when the translator of the source code makes certain assumptions, but these assumptions are not satisfied during execution. The behavior of some programming languages - most famously C and C++ - is undefined in some cases. In the standards for these languages, the semantics of certain operations is undefined. An implementation is allowed to assume...
@chewbapoclypse Have you considered serializing as text? Have you considered actually serializing the data you want (instead of raw pointers that randomly point into process space)
 
well I would like to know the right way of reading from the file and returning the proper type
 
2
Q: C++ serialization of data-structures

alexj123I'm studying serializations in C++. What's the advantage/difference of boost::serialization if compared to something like: ifstream_obj.read(reinterpret_cast<char *>(&obj), sizeof(obj)); // read // or ofstream_obj.write(reinterpret_cast<char *>(&obj), sizeof(obj)); // write // ? and, which one...

 
our book did talk about the boost library but its not until another chapter
i think this is just a lesson leading up to that
and its supposed to be flawed, so when we reach that point we understand why we need the boost library
thanks for the heads up :D
and would ya look at that next weeks lesson is Object Serialization
 
2:01 AM
@chewbapoclypse I still think it's bad C code from 1980. There's no build up from there (unless the whole point is to show how bad it is? In which case you should have been told about this).
@chewbapoclypse Here's a way to make it work (note the added flushes) coliru.stacked-crooked.com/a/322e9e9ee8e2561f
 
2:15 AM
nice the flush is to empty out the stream buffer?
 
Or, to put it more to the point, writing out the changes.
 
 
2 hours later…
3:54 AM
@milleniumbug Sorry for late reply, Thank you it's very logical, only you that give me the definite answer, the conclusion is that the standard has two meaning. It depends on the one who is interpret it.

1. Might I answer my own question by including your answer? http://stackoverflow.com/questions/40902789/does-rewind-and-fsetpos-can-also-intervene-the-c-file-append-mode-subsequent-wri

2. What is the appropriate official contact person of the C standard developer for confirming this problem? I want to ask about the certainty. An email would be better enough, I don't found anything useful
wg14 contact section maybe?
 
 
2 hours later…
Dan
6:10 AM
anyone develop c++ / wxwidgets on a mac and know if system integrity protection hoses default wxwidgets code?
 
user1593881
6:36 AM
Reading Meyers 2005, the passing by reference-to-const part, the book says no object is created. How is object not created? If no ctors or dtors are called this way then how the compiler constructs the param data? What kind of sorcery is this?
 
8:01 AM
@RawN references by definition are not objects
 
user1593881
8:18 AM
@milleniumbug I see. If passing by value calls ctors what does passing by reference to const do? If no temporary is created where does the data come from?
 
user1593881
Or maybe I am looking at this the wrong way.
 
@Unknown123 1. Sure 2. Sorry, I'm not that familiar with the standardization process. There are "Defect Reports" which is where stuff like this is reported, but normally I'd try to raise this on some mailing list related to this first (C++ for example has std-proposals for people who want to propose new features)
@RawN What do you think "refer" means in "reference"
 
user1593881
Address in memory, sort of
 
It's referring to the original object
 
user1593881
blaaaaast
 
user1593881
8:27 AM
Now I see
 
user1593881
by value creates a copy hence the calls to ctors
 
user1593881
the reference does not because there is no copy
 
@RawN Note: if the types are different (like: you pass an int to a function which expects const long&) then this isn't true
 
user1593881
@milleniumbug I see.
 
user1593881
@milleniumbug Thank you.
 
1:13 PM
Is there difference between looping and iteration
I googled but didn't found anything
 
Has anyone a source how to do integer partitioning, but not with one as the smallest element. Instead using a set of other integers?
Has anyone a source how to do integer partitioning, but not with one as the smallest element. Instead using a set of other integers?
 
Guys! Anybody know difference between looping and iteration
I think they are same
 
@afzalex yes
 
So do you know difference between them ? @Abyx
 
nwp
Search engines seem to find relevant content for integer partitioning. It should be decently easy to adapt one of the algorithms.
 
1:18 PM
8 messages moved from Lounge<C++>
 
nwp
1 message moved to Trash can
 
nwp
heh, you can move a move message which creates a new move message
 
yes, this is quite fun
 
@nwp yes, but everthing I found was about the case where you want to partition your integer into every smaller Integer, but I want to make only sets containing elements of another given set, like every combination of x in N with elements of {4,7,89} just as example
 
nwp
1:23 PM
@Aresloom I'd go with backtracking then.
 
be careful that you don't end up with a knapsack problem
 
 
4 hours later…
5:18 PM
Hey, shorthanded question. Header Files in C++ - in which order i place attributes. I know if i just got private and public private goes first. But where to place protected for best practice ?
 
@Traxstar There is no real agreement about this. Many people like to do pubic, then protected, and private last. Personally, I tend to prefer the opposite. This way, if you accidentally leave out an access specifier, the code won't build; if you do public first, then progress toward private, leaving out an access specifier can result in leaving something public you intended to make private (or protected).
I.e., private, then protected then public fails fairly safely, but public, then protected, then private fails dangerously.
 
@JerryCoffin thank you :) yeah i know there is no convention for it, but if i want to lean i want to do it as it is best practice.. :)
 
just stay consistent within the project
 
@ratchetfreak thats might be the most helpful hint ;)
how could i change the color of my output in console ?
 
nwp
5:36 PM
@Traxstar standard C++ cannot do that, you need some (OS-specific) library to do that
 
@nwp okay, thank you :)
 
6:09 PM
what is causing this:
error: call to non-static member function without an object argument
std::cout << "Ring Flaeche: " << Ring::berechneFlaeche << std::endl;
float Kreis::berechneFlaeche() const{
return radius*radius*3.141593F;
}

void Kreis::zeigeFlaeche(){
std::cout << "Kreis Flaeche: " << this->berechneFlaeche() << std::endl;
}
got it thanks in anyway :)
 
7:06 PM
I got 2 classes. Form1 implements a public function void calculate() const. I need to reimplement it with class Form2 : public Form1 cause the caluclation is a bit different. So i rewrote it. now my console says

duplicate symbol __ZN5KreisC1EPcf in:
Kreis.o
Ring.o

6 times.... why ?
 
nwp
hard to know without seeing the code, apparently you have multiple definitions of Kreis::calculate, possibly due to including a header twice
 
so which files i need to show ?
 
nwp
mostly the file that contains the definition of that function
@Traxstar is this part in the header file?
 
@nwp gist.github.com/anonymous/af8da591acd16c87978b387508e84c73 here are all files related to that problem
any ideas ?
 
nwp
I'm not seeing it
 
7:21 PM
how should a noob like me then ever figure it out :(
 
nwp
the demangler says the problem is Kreis::Kreis(char*, float) and according to the error message it is defined twice, but I'm not seeing 2 definitions and no #include "kreis.cpp" either
this is the time I'd question my build system, do a clean build and see if it goes away
 
im a fkin idiot.... there was a problem in my object file. My make file dont refresh it cause nothing changes... after removing objects and genertate them again it works - thanks for your help
 
nwp
I blame make for not tracking dependencies and making a regular make clean all the only viable option, but I have been told that it is indeed possible to have make track dependencies properly, I just don't know how.
 
yeah im just at the beginning of c++ and often i just fail cause something i changed dont got recompiled
 
 
4 hours later…
11:40 PM
Does anybody here know if abstract classes count as "enabling" dynamic binding?
 
1 message moved from Lounge<C++>
virtual functions do
can't have abstract classes without virtual functions, so
 
Yes, well, it's a requirement for an assignment, and I obviously know there ought to be at least one virtual function in an abstract class, but I figured maybe the professors don't consider it a "real dynamic binding" unless I make another member function virtual.
So I figured I'd see if it is considered dynamic binding in the C++ community in general.
 
you can always ask your prof if you have doubts
 
Yep. I'm just eager to finish it all now, I've got another project and assignment and exam preparation waiting, and it's past midnight here. But I've still got another 3-4 days for this one.
 

« first day (147 days earlier)      last day (2708 days later) »