Narue 5,707 Bad Cop Team Colleague

You've stumbled on a gray area, but the long and short of things is that what you're trying to do is illegal in standard C++, and all of the direct workarounds are also illegal. An explicit specialization needs to be in the enclosing namespace scope, which would place it outside your class:

namespace A {
  template <typename T>
  struct B {
    template <typename X>
    struct G;
  };

  template <typename T>
  template<>
  struct B<T>::G<int>;
}

The problem is that this is also illegal because you aren't allowed to specialize the nested class without also specializing the containing class. This compiles, but limits you severely:

namespace A {
  template <typename T>
  struct B {
    template <typename X>
    struct G;
  };

  template<>
  template<>
  struct B<int>::G<int>;
}

If B weren't a template class, this wouldn't be a problem. The end result is that you're stuck with indirect fixes like wrapping the whole of B and its "nested" classes in a nested namespace:

namespace A {
  namespace B {
    template <typename T>
    struct B {
    };

    template <typename X>
    struct G;

    template<>
    struct G<int>;
  }
}

Now the problem goes away because you're not trying to nest a specialized class inside a template class, and you still have the benefit of a unique scope for B, G, and all of G's specializations.

Narue 5,707 Bad Cop Team Colleague

>Can you tell me where its use C# outside of the .NET Framework.
How many times do I have to mention Mono before you actually read it?

>Firs of all C# existed long before it was standarized.
Yep, that's how it goes with all standardized languages.

>And ECMA-334 its just that. A standard of the language.
Yes, and the standard definition is the language. The standard doesn't require C# to be bound to the .NET framework. Is that such a difficult concept to understand?

>C# was born at microsoft ;-).
Java was born at Sun, what's your point?

>Visual C# IDE is one of the forums in the msdn forums there is Visual
>C# General, and Visual C# Language(so I don't see the lock to the IDE)
Note the "Visual" in the name. That's referring to the IDE, so "Visual C# General" is general discussion about the IDE and all that it contains. "Visual C# Language" is the version of C# that the IDE supports. Are you simply trying to be selectively stupid, or are you really that dense?

>As you can see C# 3.0 dosn't fallow the ECMA specification yiet. So its not C#?.
This is the first logical argument you've made, congratulations. And of course, the answer is that if the language is standardized, then any conforming implementation must support all of the features and rules of the standard. Extensions are allowed (which is where C# …

Narue 5,707 Bad Cop Team Colleague

Well, it seems you haven't had any trouble with the process of starting a thread, so now the only problem is figuring out which forum is best suited to your question. Might I suggest one of the Windows forums that matches your version?

Narue 5,707 Bad Cop Team Colleague

>My problem is that I am not quite sure how I have to think.
Think in terms of an expression tree, just like any other expression. The only difference here is accurately handling short-circuiting on top of precedence.

Narue 5,707 Bad Cop Team Colleague

If your real situation is exactly like this test, then it's because your data is wrong. Assigning all of the items to the vector is based on the line beginning with "stuff" followed by a space. So you're trying to get the last element of an empty vector, which doesn't exist, so naturally you should expect it to bomb.

Narue 5,707 Bad Cop Team Colleague

How about you give us some real code that compiles and gives you the error. :icon_rolleyes: It's kind of hard to tell you how your code is wrong when you summarize it using pseudocode.

Narue 5,707 Bad Cop Team Colleague

>cannot access private member declared in class 'System::Windows::Forms::Control
Well, the error message is pretty freaking clear about what the problem is. Are you not capable of figuring out why you can't access txtresult? It seems like you're trying to get to the Text property of a control on a different form, is that the case?

Narue 5,707 Bad Cop Team Colleague

>don't say C#.NET or Visual C# because they know
>(as we do) that they're talking about C#.NET
Well, they don't say Visual C# because it's possible to write and build C# code outside of that particular IDE. It's also rather silly to assume that the C# discussed on the MSDN forum isn't focused on .NET. And it's a safe assumption here too because most of the people asking questions are like you: completely oblivious to anything beyond Visual Studio.

>There are not other C#!
There's only one C#, and that's the C# defined by ECMA-334. There can be many implementations of C#, and .NET contains one of them. A completely different implementation is Mono, so would you call it "C# Mono" too?

>Which leads to the conclusion tha C# and C#.NET are the same thing.
C#.NET is a term invented by the clueless. I'm willing to accept it if you want to talk about C# code that uses .NET-specific libraries, but using it to refer to the language as a whole is actually an insult to all of the people who work hard to keep the language from being locked in to Microsoft platforms.

Narue 5,707 Bad Cop Team Colleague

>make the int small global
Yea, that's bad advice.

>Globalizing variables ROX!!!
You're just messing with us, aren't you?

Narue 5,707 Bad Cop Team Colleague

How about removing the string streams and simply doing this?

txtresult->text = Convert::ToString ( method );
Narue 5,707 Bad Cop Team Colleague

That's what you get for taking the path of least resistance. Now why don't you tell us what you're trying to do so we can suggest a good solution using System::string?

Narue 5,707 Bad Cop Team Colleague

>there is no need of say C#.Net when you say C# is the same as if you were saying C#.NET
Makes sense to me. So even if you're wrong in saying that C# and C#.NET are the same thing (which you are), you can still simply say C# and the effect is as if you weren't wrong. Nice how that works, isn't it? :)

>And as you should saw in my las post "Visual C#" terms exist since 2002.
I still don't see your point. Are you trying to argue that because a single implementation is called Visual C# .NET, suddenly we have to accept C#.NET as a viable name for the internationally standardized language as a whole? You don't find that ludicrous?

>And 2005 and 2008 are just the realised years.
Yes, Microsoft decided that tacking .NET onto everything is redundant for their products. That makes sense for their products as Microsoft develops and distributes the .NET framework. It's reasonably safe to assume that they won't use another implementation of the CLI specification for their development tools.

Narue 5,707 Bad Cop Team Colleague

>Just interested in the different methods everyone
>uses to plan their projects, set timelines, etc.
What is this planning thing you speak of? Just kidding, I use a variation of Scrum that's optimized for small teams.

Narue 5,707 Bad Cop Team Colleague

>I don't know the answer of the second question:
>if pattern is a array, how to optimize it?
The answer is the same.

Narue 5,707 Bad Cop Team Colleague

>Why don't you call it C#.Net compiler since they call
>it like that almost throughout the whole article ;-)
Because there's no need. If I say "Microsoft's C# compiler", you know that it's on .NET. If I say "Visual C#", you know that it's Microsoft's. And by the way, even Microsoft has recently started dropping .NET from the names of their products. For example, check out the documentation on Visual C# 2005 and Visual C# 2008.

Narue 5,707 Bad Cop Team Colleague

>Obviously you didn't read the last link that I post.
Oh, you mean the one that compares Microsoft's VB.NET compiler and C# compiler? Once again, I claim that you don't know the difference between a language and an implementation of that language.

The only link you gave that even comes close to proving your point is the second to last, but that link is nothing more than some random nameless person answering the same question who also happens to be clueless.

Narue 5,707 Bad Cop Team Colleague

>What do you mean by this?
I mean that your professor is either incompetent or doesn't care enough to learn C++ properly and thus isn't qualified to teach it.

>Is my professor not good enough?
Well, the code you attached is full of poor programming practices and broken code. If that's an example of your professor's programming ability, I wouldn't expect to get much out of the course.

>Well..I'm really clueless about linked list.
This is still incomplete until I find the time to finish it, but it still covers the basics.

>She gave this problem just hours ago and I need to submit it by tomorrow..
Sorry, but I don't believe you. If you're as new to linked lists as you claim, there's no way you would be expected to completely solve both of those problems in one evening (without cheating, of course).

Narue 5,707 Bad Cop Team Colleague

>Maybe is no 'official' bu go to this link and tell me fi
>you still think that is not correct that are the same thing.
Visual C# .NET is a compiler for C# on the .NET framework. That doesn't in any way prove that C# and C#.NET are the same thing in the way you suggest.

>Also this is the description of C# int the MSDN Visual C# Developer Center.
No, that's a description of Visual C#, which is a compiler, not the C# language itself. You seem to have difficulty differentiating between a programming language and an implementation of that language.

>My point its the closed connection C# - .Net Framework
How do you explain Mono then? Why don't you point out in the ECMA C# standard where it says that C# requires the .NET framework. I can tell you without looking that it only mentions .NET as containing the first implementation of C# and that CLI (another international standard) is based off of a subset of the .NET framework.

If you want to talk about C#, talk about C#. If you want to talk about C# in terms of .NET, talk about .NET. We're past the point where using C# means you're also using .NET.

Narue 5,707 Bad Cop Team Colleague

>my prof gave me this sample program
If you haven't modified it, then I would suggest you drop that professor and find another that can actually teach you C++.

>Please help me.I need this by tomorrow...
Please show us your attempt. If you need this by tomorrow then that means you've had plenty of time to work on it, so you should have plenty of code and experience to describe what you tried and how it didn't work.

Narue 5,707 Bad Cop Team Colleague

>I want it to be infinite, if possible.
Then you need to write something that can build a buffer of variable length from chunks returned by _cgets (_cgets_s in this case because you want length checking):

std::string console_read()
{
  std::string result;
  char buffer[82];
  std::size_t nread;

  while ( _cgets_s ( buffer, &nread ) == 0 )
    result += buffer;

  return result;
}
Narue 5,707 Bad Cop Team Colleague

>but I think this solution is not efficient.
Why? If you're just guessing or using your "programmer's intuition", you're probably wrong. Interviewers (good ones) tend to smile more on people who aren't afraid to say "I'd rather optimize clean, correct code than fix fast code". That's the sign of an experienced programmer.

Narue 5,707 Bad Cop Team Colleague

>I can't find any way around it because System::string
>has no stringstream, or any ostringstream.
You probably don't need a string stream. System::string is a surprisingly robust class that can probably handle what you want to do in a slightly different way. Perhaps if you described the problem you want to solve, someone can suggest a way to do it using System::string directly.

Narue 5,707 Bad Cop Team Colleague

>C# and C#.NET are the same thing.
Technically that's not true. C# is an internationally standardized language that isn't bound to the .NET framework as long as the implementation conforms to the CLI specification. The .NET framework is one such implementation. Mono is another.

>can anyone please enlighten me?
C# is C#. There's no such thing as C#.NET in terms of official designations, but I suppose you could refer to C#.NET if you're using .NET-specific libraries in your C# code.

Narue 5,707 Bad Cop Team Colleague

Seen it, many times over, on several versions of Windows. That joke is officially old and tired, but I expect we'll see it on every version of Windows in the future as well.

Narue 5,707 Bad Cop Team Colleague

This isn't a support forum for Bestpricedbrands. I've given you the benefit of the doubt, BPBPresident, but any further customer support posts will be treated as violations of our Keep It Spam-Free rule.

Narue 5,707 Bad Cop Team Colleague

There isn't one, that's why there are so many.

Narue 5,707 Bad Cop Team Colleague

>Oh I didn't mean to stir up any trouble or anything , sorry about that .
No worries, we want the rules to be as clear as possible, so any help in pointing out ambiguous wording is most welcome. :)

>So what is the final decision with the rules?
It looks like we've all agreed that unless the discussion involves known illegal software or acts (such as a P2P program that's illegal, or discussion of sharing illegal things with a legal program), you've got the green light.

Narue 5,707 Bad Cop Team Colleague

>while(fgets(pStrings, sizeof(pStrings), spIn))
That's bad on several levels. Now, I could tell you why it works, but I'd rather tell you why it's wrong. pStrings is an array of pointers to char, but fgets expects a single pointer to char. At the very least you should be passing pString as the first argument where i is something between 0 and 10.

But, because pString is a pointer and not an array, you can't use sizeof(pString) to get the allocated size. Finally, you need to allocate memory to each pointer, because writing to an uninitialized pointer is a Bad Thing(TM).

Narue 5,707 Bad Cop Team Colleague

>so my 1st answer it might be correct, right?
I'm having trouble understanding how you could come to that conclusion when I quite clearly said:

so I wouldn't accept this as an answer to the question.

Narue 5,707 Bad Cop Team Colleague

>C++ string classes always have string handling/parsing routines similiar to
>those found in BASIC dialect languages that make this sort of work pretty easy.
First, this is the C forum, not the C++ forum. Second, much of C++'s string functionality is available in the form of C functions if you know where to look. Finally, even C++ sucks much ass when it comes to string handling.

Dave Sinkula commented: That last sentence was brilliantly succinct. :icon_razz: +15
Narue 5,707 Bad Cop Team Colleague

>wanted you to help me out with a useful link related to the subject.....
Given that your original post can only be described as gibberish, the only useful link I can come up with is www.google.com.

Narue 5,707 Bad Cop Team Colleague

>ok but the main thing is its not anyones but mine
>the computer would only be used by me
>and the program would be made just incase my brother or sister try to go on
The guy who wrote DOS didn't expect Microsoft to buy it and turn it into a huge product. Rationalizing poor designs and sloppy code with "but it's only for me" is where a lot of the field's biggest headaches come from.

Narue 5,707 Bad Cop Team Colleague

>What is the situation where quadratic probing is better than chaining?
Chaining takes up more memory, so if storage is tight, one of the open addressing schemes would be better suited. The time it takes to chase pointers in a chained solution might also be prohibitive, in which case an open addressing scheme could be more efficient.

>if the Hashtable have a lot of elements in chaining it'll take a lot of time searching
If the hash table is well designed, the table itself will have enough buckets to keep the chains short, and the hash function will distribute values roughly equally, so this situation would only occur in degenerate cases. It's a good thing to keep in mind, but quadratic probing has degenerate cases as well (more of them), so I wouldn't accept this as an answer to the question.

>my answer for this question that It'll be like the code below
Sneaky, but that technically makes two passes through the list: one going forward and one going backward as you ride the recursion wave. To be strictly correct, you'd need an iterative solution that builds a new list from the existing nodes:

node *result = 0;

while ( head != 0 ) {
  node *save = head->next;

  head->next = result;
  result = head;

  head = save;
}

head = result;
Narue 5,707 Bad Cop Team Colleague

It's a typedef.

Narue 5,707 Bad Cop Team Colleague

To pack? Are you going on a trip? :icon_rolleyes:

>for sure i want to knw C++ and JAVA. But i dnt knw the third!
If you want to go the practical route, select a language you're likely to use. Perl and Python are both good options. If you intend to do web programming then PHP would be a good idea, and depending on what systems you want to specialize in, one of the .NET languages could help.

If you want to push your limits as a programmer, select a language that's fundamentally different than C++ and Java, such as one of the LISP variants, Haskell, or assembly.

Alex Edwards commented: Mean, but funny =P +1
Narue 5,707 Bad Cop Team Colleague

>i wanted to make it restart the computer if the wrong passwords entered
That's one of the worst ideas I've ever heard. What if other users are logged onto the system? Are you going to kill their session just because somebody fat-fingered a password? What if this program is installed on a server?! If the whole idea is to make one person wait for the computer to reboot so that brute forcing the password would take a painfully long time, why don't you just lock the account for X minutes?

If this is the extent of your security design skills, I highly recommend you not try to make an ad hoc system. Instead build on an existing and proven design, because all you're likely to do is create a huge mess that isn't nearly as secure as you think.

Narue 5,707 Bad Cop Team Colleague

Accelerated C++ by Koenig and Moo fits all of your requirements that aren't terribly subjective or reliant on a specific implementation. I think it's a fun read, but you might not. The code is standards compliant, which means it'll work on every compiler that conforms to the standard (Visual C++ is one of those, if it's newer than version 6.0).

Narue 5,707 Bad Cop Team Colleague

Sorry slick, you came here asking for us to take time out of our lives to hand you answers on a silver platter because you're too lazy to search google for 5 whole seconds. That's made painfully clear with the following incredibly arrogant statement:

Why would I go into a C++ reference and go looking for the command when someone like you could clearly help me quicker

We're not your personal slaves, and after this display of the very attitude that we abhor the most, I recommend you leave Daniweb or start a new account because you're not likely to get any help in the future.

Salem commented: Succinct and to the point as ever. +18
Narue 5,707 Bad Cop Team Colleague

>Is that considered "wrong" or weird?
Falling off the end of a function automatically returns, so it's weird in that people don't expect to see that kind of redundancy in well written code. It's not wrong though.

Narue 5,707 Bad Cop Team Colleague

>Why would I go into a C++ reference and go looking for the
>command when someone like you could clearly help me quicker
Because I'll call you a lazy retard and refuse to help you for the rest of eternity. And I'll encourage everyone else to do the same thing because you're clearly not interested in learning, which is what Daniweb is about. If you don't respect us, we won't respect you.

Narue 5,707 Bad Cop Team Colleague

I meant, you can have more than one linked list:

node *it1 = head1;
node *it2 = head2;

while ( it1 != 0 && it2 != 0 ) {
  if ( it1->data != it2->data )
    break;
}

if ( it1 == 0 && it2 == 0 )
  cout<<"Equal";
Q8iEnG commented: You saved me :D +1
Narue 5,707 Bad Cop Team Colleague

>Because he obviously knows what it is already
Your logic (or lack thereof) has stumped me. Can you explain what you mean and why you don't seem interested in doing as I suggested?

Narue 5,707 Bad Cop Team Colleague

>but for my question I didn't figure how to implement the code for TWO singly linked lists :'[
Dude, it's just like using two arrays. Please don't tell me you're as dense as that statement suggests.

Narue 5,707 Bad Cop Team Colleague

>What is c_str() doing?
Why don't you read a C++ reference and find out?

Narue 5,707 Bad Cop Team Colleague
Narue 5,707 Bad Cop Team Colleague

>I was wondering if there are any differences between the Win32 API talked about in
>this book and the one that applies to Vista or anything newer than Windows 2000.
I'd be surprised if there aren't. The API is constantly evolving, but the stuff covered in your book is still relevant.

Narue 5,707 Bad Cop Team Colleague

>Is there anyway to make %s ignore whitespace?
No, but you can use a scanset to get a little more control. For example, to read an entire line with fscanf you could do this:

char buffer[100];

fscanf ( file, "%99[^\n]", buffer );

However, in your case, selecting which strings go where is a little more complicated. You'd be better off reading an entire line and then parsing it with custom logic.

Crushyerbones commented: Thanks +1
Narue 5,707 Bad Cop Team Colleague

For starters, why are you using goto instead of a simple loop?

>it goes back to the main loop and continually loops!
It works for me. Please provide exact steps during execution to reproduce the problem.

Narue 5,707 Bad Cop Team Colleague

>I am wondering how one would append additional memory
>to the end of a pointer that already has memory allocated?
Assuming one can't use a container class that handles memory for you, realloc doesn't have a C++ alternative, so you're stuck doing it manually. Here are the steps:

1) Allocate a new block with the larger (or smaller) size.
2) Copy the data you want to keep into the new block.
3) Update any aliases you have pointing to the old block to the new block.
4) Release the memory for the old block.

The code might look like this:

#include <algorithm>
#include <cstddef>
#include <iostream>

namespace JSW {
  template <typename T>
  T *realloc ( T *p, std::size_t old_size, std::size_t new_size )
  {
    T *mem = new T[new_size];
    std::size_t n = ( new_size > old_size ) ? old_size : new_size;

    std::copy ( p, p + n, mem );
    delete[] p;

    return mem;
  }
}

int main()
{
  using namespace std;

  int *p = new int[5];

  fill_n ( p, 5, 12 );
  copy ( p, p + 5, ostream_iterator<int> ( cout, " " ) );
  cout<<'\n';

  p = JSW::realloc ( p, 5, 10 );

  fill_n ( p + 5, 5, 21 );
  copy ( p, p + 10, ostream_iterator<int> ( cout, " " ) );
  cout<<'\n';

  delete[] p;
}
Alex Edwards commented: Thank you Narue +1
Narue 5,707 Bad Cop Team Colleague

>My question is how to acess these elements
Looks like an obtuse way to intialize a multidimensional array:

#include <stdio.h>

#define X {{1,1,2,3,4,5,66},{3,2,4,1,5,0}}
#define F {{1,2,3,4,5,6,7},{1,2,3,4,5,6}}
#define I {{5,6,7,5,4,3,2},{0,9,8,7,6,5}}
#define Y {X,F,I}

int main ( void )
{
  int a[3][2][7] = Y;
  int i, j, m;

  for ( i = 0; i < 3; i++ ) {
    for ( j = 0; j < 2; j++ ) {
      for ( m = 0; m < 7; m++ )
          printf ( "%d ", a[i][j][m] );
      printf ( "\t" );
    }

    printf ( "\n" );
  }

  return 0;
}

>No where in the program they have used X.
Then you can remove it.