Sponsored Content
Full Discussion: Doubt in structure -- c++
Top Forums Programming Doubt in structure -- c++ Post 59555 by DreamWarrior on Wednesday 22nd of December 2004 02:04:41 PM
Old 12-22-2004
I think before we answer properlly we need to know what you are trying to accomplish by the if(v) statement.

I assume that you want to know if a and b members have been assigned values? If this is the case then you'll need to initialize the members to a value that the user won't enter (if possible, otherwise you'll need other members to denote that the member has been entered) and test those members against the unassigned value in the if statement as follows:

Code:
static const int UNASSIGNED_VALUE = -1;

void main()
{
   ...

   v.a = v.b = UNASSIGNED_VALUE;

   if (v.a != UNASSIGNED_VALUE && v.b != UNASSIGNED_VALUE))
   {
      cout << "Entered" << endl;
   }

   ...
}

 

10 More Discussions You Might Find Interesting

1. HP-UX

Ram structure

Hi all, I would like know if we can enter a command under UNIX (HPUX 10.xx) to know the hard ram memory structure . Thanks Dorian (1 Reply)
Discussion started by: Dorian
1 Replies

2. UNIX for Dummies Questions & Answers

if then else structure

echo name the file that you want to read read answer if then echo you must enter a file name fi cat $answer im trying to catch the error if user forget to enter the name of the file anyone can help me ? thanks:confused: (4 Replies)
Discussion started by: props
4 Replies

3. UNIX for Dummies Questions & Answers

Copying a Directory Structure to a new structure

Hi all Is it possible to copy a structure of a directory only. e.g. I have a file with the following entries that is a result of a find :- /dir1/dir2/file.dbf /dir1/dir2/dir3/file1.dbf /dir1/file.dbf I want to copy these to a directory and keep the structure however starting at a new dir... (8 Replies)
Discussion started by: jhansrod
8 Replies

4. UNIX for Advanced & Expert Users

MV files from one directory structure(multiple level) to other directory structure

Hi, I am trying to write a script that will move all the files from source directory structure(multiple levels might exist) to destination directory structure. If a sub folder is source doesnot exist in destination then I have to skip and goto next level. I also need to delete the files in... (4 Replies)
Discussion started by: srmadab
4 Replies

5. Shell Programming and Scripting

Need help in Directory Structure

I have writen the following code to show the dirctory structure. Can any body help me for using the recursive function in this code? echo "-(0)" echo "$HOME-(1)" cd ~ set * for i in `ls $HOME` do if then echo ".....${i}" cd... (5 Replies)
Discussion started by: murtaza
5 Replies

6. Programming

Search attributes in one structure using the values from another structure

Hello Groups I am trying to find out ways of comparing a value from a 'c' structure to a value in another 'C' structure. the 'C' structure can be a List or liked list as it contains lot many records. if we loop it in both the structures it is going to consume time. I am looking for a simple... (3 Replies)
Discussion started by: dhanamurthy
3 Replies

7. UNIX for Dummies Questions & Answers

Size of Structure

How can we find size of a structure with out using sizeof operator? Thanks, Harika (2 Replies)
Discussion started by: harikamamidala
2 Replies

8. Shell Programming and Scripting

condensed if then structure

Hi all, I was wondering if it was possible to put a command in an if statement. I wrote something like: grep -q 'santiago' file (( $? )) && echo text not found || echo text found I would like to write something like this but it doesn't work: (( grep -q 'santiago' file )) && echo text not... (2 Replies)
Discussion started by: chebarbudo
2 Replies

9. UNIX for Dummies Questions & Answers

Directory Structure

Hi... I have a directory which has multiple directories and sub directories inside... what command should i use to get a list of all these directories, without the filenames.... (2 Replies)
Discussion started by: saharookiedba
2 Replies

10. Shell Programming and Scripting

Wget structure

Im reading a lot about wget and have really enjoyed using it. However I see a lot of tutorials that will show several ways. I want to be able to write scripts in gedit so I was wondering what is the best process to do this instead of just running them in the terminal?? (3 Replies)
Discussion started by: graphicsman
3 Replies
FBB::PtrIter(3bobcat)						   Error handler					     FBB::PtrIter(3bobcat)

NAME
FBB::PtrIter - Iterator returning pointer when dereferenced SYNOPSIS
#include <bobcat/ptriter> DESCRIPTION
The PtrIter class template implements an input iterator whose operator* returns the address of the element the iterator refers to. Con- sider a std::unordered_map<std::string, DataType>. Its begin member returns an iterator whose operator* returns a std::pair<std::string, DataType> (const) &. This is usually what you want, but now assume we want to display the map's contents, sorted by its keys. Sorting can simply be performed by defining a support vector containing pointers to the elements in the map, and then sorting the strings the pointers point at. PtrIter is a tool that can be used to construct such a support vector, as shown in the EXAMPLE section. PtrIter is a class template requiring one template type parameter: Iterator, the iterator's type (e.g., vector<string>::iterator) PtrIter's users don't have to specify PtrIter's template type. The function template ptrIter, when provided with an iterator returns the matching PtrIter object. NAMESPACE
FBB All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB. INHERITS FROM
std::iterator<std::input_iterator_tag, ...> FREE FUNCTION
o PtrIter<Iterator> ptrIter(Iterator const &iter): this function template returns a PtrIter object for the function's Iterator argument. This function template simplyfies the con- struction of a PtrIter as no template parameters need to be specified (see also the EXAMPLE section) CONSTRUCTORS
o PtrIter(Iterator const &iter): The iter parameter must be initialized with an existing input iterator, offering operator*, operator++, operator== and operator!=. As PtrIter is a class template, its template type parameters must be specified when defining a PtrIter object. E.g., PtrIter<set<string>::iterator> PtrIter(mySet.begin()); The copy and move constructors are available. OVERLOADED OPERATORS
o PtrType operator*() const: the address of the entity the iterator refers to is returned; o PtrIter &operator++(): the iterator is (pre)incremented to the next position; o bool operator==(PtrIter const &other) const: true is returned if the two iterators are equal; o bool operator!=(PtrIter const &other) const: true is returned if the two iterators are unequal; The copy and move assignment operators are available. DEFINED TYPE
PtrIter defines the following type: o typedef decltype(&*Iterator()) PtrType: MEMBER FUNCTIONS
All members of std::iterator<std:::input_iterator_tag, ...> are available, as FBB::PtrIter inherits from this class. EXAMPLE
#include <algorithm> #include <unordered_map> #include <vector> #include <cstring> #include <iostream> #include <bobcat/ptriter> using namespace std; using namespace FBB; int main() { cout << "Enter lines, the first word will be the map's key; " "^D when done. "; string key; string line; unordered_map<string, string> map; while (cin >> key && getline(cin, line)) // fill the map map[key] = line; cout << ' '; // initialize a support vector<decltype(&*map.begin())> // vector, using ptrIter support(ptrIter(map.begin()), ptrIter(map.end())); // sort 'support' typedef unordered_map<string, string>::value_type VT; sort(support.begin(), support.end(), [&](VT const *p1, VT const *p2) { return strcasecmp(p1->first.c_str(), p2->first.c_str()) < 0; } ); for(auto &element: support) // display sorted by key cout << element->first << ' ' << element->second << ' '; } FILES
bobcat/ptriter - defines the class interface SEE ALSO
bobcat(7) BUGS
None Reported. DISTRIBUTION FILES
o bobcat_3.01.00-x.dsc: detached signature; o bobcat_3.01.00-x.tar.gz: source archive; o bobcat_3.01.00-x_i386.changes: change log; o libbobcat1_3.01.00-x_*.deb: debian package holding the libraries; o libbobcat1-dev_3.01.00-x_*.deb: debian package holding the libraries, headers and manual pages; o http://sourceforge.net/projects/bobcat: public archive location; BOBCAT
Bobcat is an acronym of `Brokken's Own Base Classes And Templates'. COPYRIGHT
This is free software, distributed under the terms of the GNU General Public License (GPL). AUTHOR
Frank B. Brokken (f.b.brokken@rug.nl). libbobcat1-dev_3.01.00-x.tar.gz 2005-2012 FBB::PtrIter(3bobcat)
All times are GMT -4. The time now is 01:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy