[QUOTE=WTF Nuke;44975043]See I did that, but I got
[code]cmodel.h(8): fatal error C1001: An internal error has occurred in the compiler.[/code][/QUOTE]
Congratulations, you found a compiler bug!
All you can do is try to reduce it to a minimal replicating test case, then report it :v:
[QUOTE=WTF Nuke;44975043]See I did that, but I got
[code]cmodel.h(8): fatal error C1001: An internal error has occurred in the compiler.[/code][/QUOTE]
Which compiler are you using?
I figure posting here is better than starting a new thread for it, so...
I want to make a relatively simple game that's basically a 'choose your own adventure/RPG' that focuses mostly on descriptive text with some very basic top-down graphical representations of the world to help out a bit. Sort of like T.I.T.S, only more RPG focused.
Most of my programming experience was with C# a few years back, but I'd prefer working with something that's easier to get the base of my game up and running. Anyone got any suggestions for what language/tools I should try out?
[URL]https://github.com/Proclivitas/CPP_Early_Objects_Eighth_Edition/blob/master/Chapter 3/Problem 3/Source.cpp[/URL]
This is a question about how to properly "say" something in my code which is obvious to me and I think should be obvious to another person, but I would like to have another's input.
The line in question is thirty-six. I am totaling the annual cost of bills as you can see, and I was wondering I should be making a variable named as such "monthsInYear" or leave it as twelve for obvious reasons.
PS I am trying to solve each problem in chronological order in which the book has provided information. (I assume a const variable might be used here, but it has not been taught yet; if that is the acceptable answer to my question so be it.)
I think it's fine the way it is, especially because the other variable is named monthlyTotal so you know it has something to do with months. From there the 12 should be obvious.
[url]http://i.imgur.com/opXq630.png?1[/url]
Please tell me how to get rid of this constant pop for overloads after every insertion operator :( It's super annoying and covering my code.
[QUOTE=Proclivitas;44978746][url]http://i.imgur.com/opXq630.png?1[/url]
Please tell me how to get rid of this constant pop for overloads after every insertion operator :( It's super annoying and covering my code.[/QUOTE]
To be honest that kind of function definition help is what you're getting from using visual studio, however [URL="http://msdn.microsoft.com/en-us/library/vstudio/ecfczya1%28v=vs.100%29.aspx"]this[/URL] ought to help (look at the bit on parameter information)
[QUOTE=rookwood101;44978981]To be honest that kind of function definition help is what you're getting from using visual studio, however [URL="http://msdn.microsoft.com/en-us/library/vstudio/ecfczya1%28v=vs.100%29.aspx"]this[/URL] ought to help (look at the bit on parameter information)[/QUOTE]
I know that it's a big part of VS, I would just love the ability to turn it on/off for certain activities :3
[QUOTE=Bumrang;44975782]Which compiler are you using?[/QUOTE]
VS2013 update 2.
[CODE]
private T[] bag;
T tSpace;
for (int i = 0; i < this.bag.length; i++) {
for (int j = 1; j < this.bag.length - i; j++) {
Integer previousIndex = j - 1;
if ((Integer) this.bag[previousIndex] == 0) {
tSpace = this.bag[previousIndex];
this.bag[previousIndex] = this.bag[j];
this.bag[j] = tSpace;
}
}
[/CODE]
How do I sort a generic array?
C#? [code]Array.Sort(array, comparer)[/code]
[QUOTE=Tamschi;44982972]C#? [code]Array.Sort(array, comparer)[/code][/QUOTE]
Java. I was trying to do a bubble sort without calling the Collections class.
[QUOTE=blacksam;44983186]Java. I was trying to do a bubble sort without calling the Collections class.[/QUOTE]
Oh right, there's [I]Integer[/I]... I think you need to require IComparable or something like that on the generic type, or use a comparer there too.
[QUOTE=blacksam;44983186]Java. I was trying to do a bubble sort without calling the Collections class.[/QUOTE]
Where you specify the generic type (<T>), you can restrict it to implement certain interfaces. So if you do
[code]public <T extends Comparable<T>> void sort(T[] array) {...}[/code]
you can only call it with a type T that implements Comparable<T> (note that in the code the word is extends even though it's an interface). This will let you call t1.compareTo(t2)
You can also be more general and provide a comparator object similar to what Tamschi recommended for C#
[code]public <T> void sort(T[] array, Comparator<T> comparer) {...}[/code]
This lets you use comparer.compare(t1, t2)
Actually if you look at the documentation for [url=http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html]Collections[/url], it uses <T extends Comparable<? super T>> and Comparator<? super T> instead. This is even more general: <? super T> is any class that is a superclass of T. This would, for example, let you use a Comparator<Number> for an array of Integers.
C++ Question.
I have a class Minion. I have it added to two vectors. If I change a member variable of a certain instance of Minion (in this case, inside vector queue I change a minion's variable "canSpawn" to true), will it also change the variable of the minion inside the other vector?
If they are of the type std::vector<Minion> then no. Each vector has its own Minion. If they are pointers (std::vector<Minion*>) then yes, because they point to the same Minion.
[QUOTE=Shadow187(FP);44989770]C++ Question.
I have a class Minion. I have it added to two vectors. If I change a member variable of a certain instance of Minion (in this case, inside vector queue I change a minion's variable "canSpawn" to true), will it also change the variable of the minion inside the other vector?[/QUOTE]
If both vectors reference the same memory location then yes, to prevent that you could either create separate objects for each vector or use a struct.
[QUOTE=cartman300;44989929]If both vectors reference the same memory location then yes, to prevent that you could either create separate objects for each vector or use a struct.[/QUOTE]
C++ classes and structs do not differ in this regard.
[CODE]public BagInterface intersection(BagInterface anotherBag) {
ResizableArrayBag<T> intersectionBag = new ResizableArrayBag();
anotherBag.reduceArray();
this.reduceArray();
T[] anotherBagArray = (T[]) anotherBag.toArray();
Arrays.sort(anotherBagArray);
Arrays.sort(this.bag);
if (this.bag.length <= anotherBagArray.length) {
for (int i = 0; i < anotherBagArray.length; i++) {
if (anotherBagArray[i].equals(this.bag[i])) {
intersectionBag.add(anotherBagArray[i]);
}
}
} else if (this.bag.length > anotherBagArray.length) {
for (int i = 0; i < this.bag.length; i++) {
if (anotherBagArray[i].equals(this.bag[i])) {
intersectionBag.add(this.bag[i]);
}
}
}
intersectionBag.reduceArray();
return (ResizableArrayBag) intersectionBag;
}[/CODE]
[CODE]
ResizableArrayBag<Integer> aBag1 = new ResizableArrayBag<Integer>();
ResizableArrayBag<Integer> aBag2 = new ResizableArrayBag<Integer>();
aBag1.add(1);
aBag1.add(1);
aBag1.add(2);
aBag2.add(2);
aBag2.add(1);
aBag2.add(3);
aBag2.add(3);
System.out.println("Intersection " + aBag1.intersection(aBag2).toString());
[/CODE]
I keep getting an ArrayIndexOutOfBoundsException. I can compare arrays of equal size. How do I compare arrays of different lengths?
I think you have those if's backwards (and you only need the 1 check, so that second one should be just else not an else if)
If this.bag.length > anotherBag.length you can't loop over the size of this.bag because it will be out of bounds when you compare it to anotherBag[i]. Similarly for the other case.
why is it not a good idea to use system("PAUSE")? every tutorial i see uses it
ah ok thanks, a lot of these tutorials are not helping me lol
[QUOTE=confinedUser;44990970]ah ok thanks, a lot of these tutorials are not helping me lol[/QUOTE]
That's the usual situation with common and/or old programming languages, tons of bad advice floating around.
[QUOTE=confinedUser;44990970]ah ok thanks, a lot of these tutorials are not helping me lol[/QUOTE]
If you want high quality, I'd recommend getting a book, especially one from [url]http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list[/url] I got accelerated c++ and it helped me understand a lot about the language. There are books for any level on that list.
Anyone used Gwen.net before? I have a silly bugs that i can't seem to fix.
Image first,description later:
[imghttp://i.imgur.com/WEHYM3o.png[/img]
I added a button to a window using window.AddChild(b); (where b is a button which has text, a size and a position). But it shows up like that.
I tried forcing it to redraw (both the button and the window) after creation, invalidating them both. Accessing the child list directly. It all show ups like that. BUT, when i click the window, the button extra disapears and everything is as normal.
The code is use atm is this:
[CODE]
var window = new WindowControl(Canvas, "Test", false);
window.SetSize(500, 500);
window.SetPosition(0, 0);
Button b = new Button(Canvas);
b.Text = "Test button";
b.Width = 100;
b.Height = 25;
b.SetPosition(10, 10);
window.AddChild(b);[/CODE]
(yes calling a variable b is bad, it's just for example purposes :p)
Also, how would i achieve a window with a close button?
Edit: Found it, should have used ..new Button(Window); :v:
In Haskell.
[code][1,2..1000000] ++ [1,2,3][/code]
That's slow right? It has to go through a million elements, but why can't it just optimize it at a certain size? Prepend and start indexing them?
But I guess that comes with it's own complications and in the end it's just faster for the programmer to rewrite the algorithm.
Am I right?
[editline]5th June 2014[/editline]
Not even sure why I asked, I pretty much answered my own question but if anyone has any input to add that'd be cool beans.
Well I think there's the problem that ++ isn't tail recursive (someone correct me if I'm wrong about that), but other than that because of lazy evaluation it doesn't do the concatenation until you need it. In that case you are already looking at a million elements so the concatenation doesn't add much.
There's probably a way to define a list like that in such a way that it is tail recursive.
This should work. I don't think it's any better than just using concatenation though.
[code]map (\x -> (mod x 1000000) + 1) [0..1000002][/code]
Map is also not tail recursive by the way. This is worse than concatenation because of the extra operations.
[QUOTE=rookwood101;44991812]If you want high quality, I'd recommend getting a book, especially one from [url]http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list[/url] I got accelerated c++ and it helped me understand a lot about the language. There are books for any level on that list.[/QUOTE]
i really appreciate it, i found a good book by stroustrup been reading it and i found that using keep_window_open() is relatively better than cin.get although using the keep window open has me include a shitload more header files lol
I found the definition of that keep_window_open function [url=http://www.stroustrup.com/Programming/std_lib_facilities.h]here[/url] (near the bottom):
[code]inline void keep_window_open()
{
cin.clear();
cout << "Please enter a character to exit\n";
char ch;
cin >> ch;
return;
}[/code]
So there's hardly a difference between that and cin.get, at least in terms of how it prevents the window from closing.
Sorry, you need to Log In to post a reply to this thread.