Win a copy of Terraform in Action this week in the Cloud forum!

Eric Mitchell

Greenhorn
+ Follow
since Jun 28, 2014
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
3
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Eric Mitchell

Well, looks like I solved my own problem actually. I will write what happened in case someone has a similar problem:

Header files should only include DECLARATIONS. The initializations turned them into DEFINITIONS. I also made both static and DECLARED them in the class, but put their initialization(DEFINITION) into the .CPP file. I will post the revised code.


6 years ago
Hello friends,

I am having a very frustrating linker error on what i thought was a very simple program. Here is what the linker says:

Severity Code Description Project File Line
Error LNK1169 one or more multiply defined symbols found Library C:\...\Library\Debug\Library.exe 1
Error LNK2005 "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * month_names" (?month_names@@3PAV?$basic_string@DU?$char_traits@D@std@@V? $allocator@D@2@@std@@A) already defined in App.obj Library C:\...\Projects\Library\Library\Date.obj 1

Here is the code:




Any insight as to why this is happening would be great. I'm not great with header files yet, so it is probably something simple.
6 years ago
Is this pointer usage what is most commonly used? Is this used only for structs? It seems awkward and unfamiliar to me. I know that a more common implementation of 'Date' is as a class, but I am using a struct as a practice exercise.

The reason I ask is that when I try this with Date as a class, everything works fine. Why does the compiler know the size of the Date class, but not the Date struct?
6 years ago
What fix does my given code need though? I get these errors on compilation:

Error C2079 'today' uses undefined struct 'Date' Date1 c:...\projects\date1\date1\main.cpp 9
Error (active) incomplete type is not allowed Date1 c:\...\Projects\Date1\Date1\Main.cpp 9

It looks like I have #included it the same way as your example...
6 years ago
It is hard to find a good example of file structure for c++ programs that really show how to use header files. I will post what I expected to work:


I kept things as minimal as possible for reading. Please help. I have researched this and found no answer. This structure is my attempt to mimic Bjarne Stroustrup's.
6 years ago
As it turns out, that is exactly what is happening. I wrote some code to print the strings held in argv and it was a long list of files. Thank you for your help.
6 years ago
The strangest thing is happening with this program: It crashes whenever it is given a '*' as a command line argument. If we modify it to use 'x' instead for multiplication, there are no problems. WHAT IS GOING ON HERE!
6 years ago
Why does this program crash every time I run it?
6 years ago
Here is what is printed:
For Input String: ""
For Input String: ""
For Input String: ""
For Input String: ""
etc.
null

But how can it be null? A value is assigned to each space in the squares array during the collectInfo() method.
7 years ago
I have been writing a Sudoku Solver and it compiles, but when it comes time to run, It throws a null Pointer Exception! I have looked at it for a million years and can NOT figure it out. I will post the code in its entirety, but only a few lines are the problem (I hope).


The nullPointer happens at line 192. Thank you in advance.
7 years ago
alright, I got it! Yes, I attempted to write the statement someNode.next=someOtherNode, but had instead written newNode=occupiedNode.next (Line 43). I had also written in several places, "if (...key==otherKey)" like lines 92 & 105, when it should have been "key.equals(otherKey)". Also changed variables for list and count to be non-static, Not sure what I was thinking there...Anyways, thank you so much for your help!
7 years ago
Alright, so I have been trying to write a hash table class from scratch (as a programming exercise), but when it comes to testing, nothing is coming out right! For instance my "containsKey" method will return false no matter what, and my "get(key)" method can never find the keys. I assume it is all due to ONE central problem, but I can't find it. I have spent a lot of time looking at this, and I thank you in advance for your help.
7 years ago
THANK YOU!

just changed line 65 to read


instead and it runs perfectly now, thank you!
7 years ago
This program is for an exercise in a text book. It is supposed to create an array of random strings and sort them according to their HTML numbers. It creates the array correctly and even compiles correctly, but has a null pointer exception when it comes to the sorting. (I have cut out other parts of the program that were irrelevant).

the lines that produces the null Pointer Exception is line 24. if(array[i].charAt(0)>array[maxIndex].charAt(0))...and 53.stringSelectionSort(stringArray);

thank you.

7 years ago
well, it is supposed to give the base-10 value of a hexadecimal, but the numbers do not come out right. For instance, if I put in "1" it comes out with 49. "0" comes out as 48. Letters come out correctly, but only when there is only one character of input.
7 years ago