Search Results

Showing results 1 to 36 of 36
Search took 0.01 seconds.
Search: Posts Made By: titaniumdecoy
Forum: C++ Aug 12th, 2008
Replies: 3
Views: 1,020
Posted By titaniumdecoy
When you build and run a project in Xcode, the executable is placed in the build/Debug (or build/Release) folder relative to the project directory.
Forum: C++ Jul 22nd, 2008
Replies: 8
Views: 559
Posted By titaniumdecoy
Perhaps your compiler decided to optimize the code by substituting the contents of the function for the function call as if the function were declared inline.
Forum: C++ Jul 22nd, 2008
Replies: 16
Views: 4,434
Posted By titaniumdecoy
If you are assigning the return value of the new operator to arrays, it had better be a pointer.

Space in memory is reserved whether you use dynamic allocation or not. What that space holds is...
Forum: C++ Jul 22nd, 2008
Replies: 16
Views: 4,434
Posted By titaniumdecoy
Just because it works with your compiler does not mean it will work with others. The initial values of an array are undefined in C++, which means they may be 0 or anything else.

To initialize an...
Forum: C++ Jul 21st, 2008
Replies: 16
Views: 4,434
Posted By titaniumdecoy
As this is C++, you can use STL functions to do the work for you:
#include <algorithm>
#include <iostream>

int main()
{
int array[] = { 2, 5, 8, 1, 4, 2 };
size_t array_size = 6;
...
Forum: C++ Jul 15th, 2008
Replies: 13
Views: 1,292
Posted By titaniumdecoy
Reverse psychology works well, it would seem. :P
Forum: C++ Jul 15th, 2008
Replies: 13
Views: 1,292
Posted By titaniumdecoy
I learned Java as my first programming language by reading Beginning Java by Ivor Horton. The book weights in at over 1000 pages. I found that an encyclopedic tutorial is an excellent way to learn...
Forum: C++ Jul 13th, 2008
Replies: 3
Views: 392
Posted By titaniumdecoy
Read the comments in the input function.
Forum: C++ Jul 11th, 2008
Replies: 2
Views: 422
Posted By titaniumdecoy
There is no operator for raising to powers in C++ similar to the ** operator in Python. You can do the multiplication or use the pow library function as suggested.
Forum: C++ Jul 10th, 2008
Replies: 4
Views: 1,368
Posted By titaniumdecoy
Is there a difference, in terms of performance, between the two loops below? (myvec is type std::vector<int>.)
std::vector<int>::const_iterator pos;
for (int i = 0; i < N; i++) {
pos =...
Forum: C++ Jul 8th, 2008
Replies: 3
Views: 976
Posted By titaniumdecoy
You can use the std::noskipws stream manipulator to alter the behavior of the stream. See here (http://www.cplusplus.com/reference/iostream/manipulators/noskipws.html).
Forum: C++ Jul 8th, 2008
Replies: 7
Views: 945
Posted By titaniumdecoy
That is a neat trick. Thanks.
Forum: C++ Jul 7th, 2008
Replies: 4
Views: 922
Posted By titaniumdecoy
I figured it out. I was calling the std::vector constructor with the arguments reversed (as well as providing an incorrect initial size). The solution:

Polynomial(int val = 0, int exp = 0) :...
Forum: C++ Jul 7th, 2008
Replies: 4
Views: 922
Posted By titaniumdecoy
coefs is initialized in the initializer list of the constructor:

Polynomial(int val = 0, int exp = 0) : coefs(0, exp), degree(exp)


Am I missing something? Thanks.
Forum: C++ Jul 7th, 2008
Replies: 4
Views: 922
Posted By titaniumdecoy
The default copy constructor should work for the Polynomial class below because it does not contain any dynamic data types. However, when I create a new Polynomial via the copy constructor, it...
Forum: C++ Jul 7th, 2008
Replies: 7
Views: 945
Posted By titaniumdecoy
I did some searching on this topic but couldn't find anything definitive.

Are basic types automatically initialized to 0 in C++ when allocated via new? For example, are all values of nums...
Forum: C++ Jul 7th, 2008
Replies: 48
Views: 3,274
Posted By titaniumdecoy
You are calling payroll::setvariables twice with 4 arguments, whereas the function definition specifies that it requires 7 arguments. In addition, you have not defined the function, only declared it.
Forum: C++ Jul 7th, 2008
Replies: 11
Views: 1,618
Posted By titaniumdecoy
[deleted]
Forum: C Jul 7th, 2008
Replies: 7
Views: 1,980
Posted By titaniumdecoy
How about this:

char *ns = malloc(l * sizeof(*ns));
Forum: C++ Jul 7th, 2008
Replies: 2
Views: 683
Posted By titaniumdecoy
Alternatively you can use STL functions:
#include <string>
#include <algorithm>
...
std::string::iterator end_pos = std::remove(str.begin(), str.end(), '\\');
str.erase(end_pos, str.end());
Forum: C++ Jul 6th, 2008
Replies: 13
Views: 1,394
Posted By titaniumdecoy
Ignore the pass-by-value/pass-by-reference discrepancies in the function declarations in my previous post.
Forum: C++ Jul 6th, 2008
Replies: 13
Views: 1,394
Posted By titaniumdecoy
gcc 4.0.1

@vijayan121: Thanks for the info, I have updated my code.

----------

As a matter of style, is it better (in general) to write:
template <typename T1,
typename T2,
...
Forum: C++ Jul 5th, 2008
Replies: 13
Views: 1,394
Posted By titaniumdecoy
sarehu's code works for me.
Forum: C++ Jul 5th, 2008
Replies: 13
Views: 1,394
Posted By titaniumdecoy
Thanks, that is just what I was looking for.

What does this mean: template <typename> class Container? I can figure out what it does, but typename is not followed by a name, which I find...
Forum: C++ Jul 4th, 2008
Replies: 13
Views: 1,394
Posted By titaniumdecoy
I have a template function as follows:

template <typename T>
int my_func(T& arg)

T is expected to be of type map<T1, T2>. T1 is expected to be of a basic type (int, long, etc.) and T2 is...
Forum: C++ Jul 4th, 2008
Replies: 2
Solved: Is this legal?
Views: 488
Posted By titaniumdecoy
If I declare a struct node, is the following legal in C++?

node nodes_array[vector.size()];


I know this is not legal in C. However, my C++ compiler does not complain. Is this only in recent...
Forum: C++ Jul 4th, 2008
Replies: 18
Views: 2,658
Posted By titaniumdecoy
Like ruggedrat said, a breadth first search will suffice. Starting at M, mark each reachable node as distance 1; from those nodes, mark each reachable node that has not already been visited as...
Forum: C++ Jul 4th, 2008
Replies: 9
Views: 846
Posted By titaniumdecoy
Ah, I'm an idiot. Some of the entries in Board::pieces were NULL. Thanks for pointing that out.
Forum: C++ Jul 4th, 2008
Replies: 9
Views: 846
Posted By titaniumdecoy
Thanks for the info.


The move function is empty: void Pawn::move(int rank, int file) { }. I should mention that Pawn (the type that is returned by board[0][0]) is a subclass of the pure...
Forum: C++ Jul 3rd, 2008
Replies: 9
Views: 846
Posted By titaniumdecoy
Although my last question has not yet been answered, I have another. What is the difference between Piece* const* and Piece** const?
Forum: C++ Jul 3rd, 2008
Replies: 9
Views: 846
Posted By titaniumdecoy
Here is my code for Board.h:

#ifndef BOARD_H
#define BOARD_H

#include <iostream>
#include "Piece.h"

static const int BOARD_DIM = 8;
Forum: C++ Jul 3rd, 2008
Replies: 9
Views: 846
Posted By titaniumdecoy
@vijayan121: That would work, but I want to be able to modify the Piece corresponding to board[0][0].

Board b;
const Piece *p = b[0][0];

p.move(0,0); // not legal

Does this mean that I...
Forum: C++ Jul 3rd, 2008
Replies: 9
Views: 846
Posted By titaniumdecoy
I am writing a chess game to familiarize myself with the C++ language. I have a Board class which contains a 2D array of pointers to Piece objects. I want to implement Board::operator[] such that...
Forum: Java Mar 28th, 2007
Replies: 3
Views: 2,373
Posted By titaniumdecoy
An even better way to do this would be to create a Person class with the appropriate fields, and create a new class that implements Comparator for each desired sort order. See here...
Forum: Java Mar 28th, 2007
Replies: 10
Views: 2,750
Posted By titaniumdecoy
float fah = console.nextFloat();
Forum: Java Mar 23rd, 2007
Replies: 7
Views: 11,759
Posted By titaniumdecoy
You can use a javax.swing.JFormattedTextField with a java.text.NumberFormat as the format. For example:
numberField = new JFormattedTextField(NumberFormat.getInstance());
Showing results 1 to 36 of 36

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC