I want to use a vector string class, but troubling in compile

#include <iostream>
#include <string>
#include <vector>
using namespace std;

class Subdomain
{
public:
// Default constructor
Subdomain()
{
}

// Init constructor
Subdomain(string& address)
{
Address.push_back(address);
}

void SetAddress(const string& address)
{
Address.push_back(address);
}

// Validates subdomain part and returns true if the Address corresponds
// to a well formed email subdomain part, returns false otherwise
bool IsValid();

private:
// The encapsulated subdomain part
vector<string> Address;
};
Please use [code] tags and show us the error the compiler is giving you.
You should try adding a main function
I do have a main function, but the whole project is too big to post here.
// Subdomain.h - subdomain part validation class declaration
// Written by Meng Jin

#pragma once

#include <string>
using namespace std;

[code]class Subdomain: public vector<string>
{
public:
// Default constructor
Subdomain()
{
}
// Default constructor
Subdomain(const string& address)
{
[code] Address = address;
}
void SetAddress(const string& address)
{
[code] Address = address;
}

// Validates subdomain part and returns true if the Address corresponds
// to a well formed email subdomain part, returns false otherwise
bool IsValid();

private:
// The encapsulated subdomain part
[code] string Address;
};

does this one function the same as the one above?
I tried use the below codes outside Subdomain class, if I use member function from vector push_back or operator [], an error c2039: '_Swap_adl' is not a member of 'std' will happen in vs2008

Subdomain newSubdomain(substring)
newSubdomain.push_back(substring)
I want to make subdomain a string vector class,

like subdomain[0] is a string
subdomain[1] is a string, too
and so on

but I have no idea to do that, I am keep tring in my ways, does anyone can show me how to do it, or a clue?
So what you want to do is something like this?
1
2
Subdomain sbd;
sbd[0] = "String";
Last edited on
There's no such thing as a string vector class. You mean a vector of strings?
I'm pretty sure you can't inherit directly from a specialization of a template. (I may be wrong, someone please check.) But you can write a wrapper for the vector of strings you have in mind. Just make a member of your class a std::vector<string>.
Once again, either use code tags or put your code up on something like pastebin.
Topic archived. No new replies allowed.